301将多个域重定向到域IIS的子目录

时间:2013-10-11 09:29:33

标签: iis redirect url-rewriting http-redirect

在IIS 7中,如何将多个域重定向到以下

的子目录
Request                                     Redirect to
--------------------------------------------------------------------------
www.domain.fr                        www.newdomain.com/fr/
www.domain.com.pk                    www.newdomain.com/pk/
www.domain.co.th                     www.newdomain.com/th/
www.xyzdomain.com                    www.newdomain.com/xyz/

我有很多域重定向到IIS中的一个网站,我必须将它们重定向到相关的子目录,保持301重定向(SEO友好)

感谢您的帮助,如果有人知道的话。

1 个答案:

答案 0 :(得分:0)

我找到了301重定向的另一种方式,就像这样:

  1. 将您的所有网域放入单个IIS网站。 (第一个网站) (例如www.domain.fr,www.domain.com.pk,www.domain.co.th,www.xyzdomain.com)

  2. 为主网站创建另一个IIS站点(第二个站点) (例如www.newdomain.com)

  3. 现在根据您的条件设置一个asp / php / asp.net代码进行重定向,在我的例子中,我使用了asp经典并添加了一些代码:

  4.  
    If InStr( UCase(Request.ServerVariables("SERVER_NAME")),  UCase("www.domain.fr") ) > 0 Then
        Response.Status="301 Moved Permanently" 
        Response.AddHeader "Location","http://www.newdomain.com/fr/" 
        Response.End
    ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("www.domain.com.pk") ) > 0  Then
        Response.Status="301 Moved Permanently" 
        Response.AddHeader "Location","http://www.newdomain.com/pk/" 
        Response.End