Iis 7 IIS-如何测试www到非www转发

Iis 7 IIS-如何测试www到非www转发,iis-7,seo,Iis 7,Seo,我正在尝试解决基于windows的主机中的www和非www url问题, 我已经做了下面给出的一些工作,但我需要检查它是否正确,它是否会解决我的问题。 使用经典asp构建网站页面 使用go daddy在IIS 7.0上(共享)托管 我的global.asax编码如下 void Application_BeginRequest(object sender, EventArgs e) { string newUrl = string.Empty; try {

我正在尝试解决基于windows的主机中的www和非www url问题, 我已经做了下面给出的一些工作,但我需要检查它是否正确,它是否会解决我的问题。 使用经典asp构建网站页面 使用go daddy在IIS 7.0上(共享)托管

我的global.asax编码如下

  void Application_BeginRequest(object sender, EventArgs e)
    {
    string newUrl = string.Empty;
    try
    {
        if (HttpContext.Current.Request.Url.AbsoluteUri.ToLower().StartsWith("http://itcorner.org.in"))
        {

            if (HttpContext.Current.Items["UrlRewritingNet.UrlRewriter.VirtualUrl"] != null)
                newUrl = "http://www.itcorner.org.in" + HttpContext.Current.Items["UrlRewritingNet.UrlRewriter.VirtualUrl"].ToString();
            else
                newUrl = HttpContext.Current.Request.Url.AbsoluteUri.ToLower().Replace("http://itcorner.org.in", "http://www.itcorner.org.in");



            Response.Status = "301 Moved Permanently";
            Response.StatusCode = 301;
            Response.StatusDescription = "Moved Permanently";
            Response.AddHeader("Location", newUrl);
            Response.End();
        }

    }
    catch (Exception ex)
    {
        Response.Write(ex.Message);
    }
}

谢谢

这不是经典的ASP,而是ASP.NET。你试过密码了吗?为什么不直接使用IIS URLEWRITE为您执行此操作?是的,我尝试了该代码,是的,此代码位于asp.net和经典asp中的站点页面中,认为IIS服务器同时支持这两种功能,我无法使用IIS URLEWRITE,因为我没有根访问权限,因为这是共享主机。确定……上述代码是否有效?如果这是IIS7,那么您的共享主机应该已经安装了UrlRewrite。