Question

In IIS 7 how to do 301 redirect of Multiple domains to sub directories for the following

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/

I have many domains redirect to one single website in IIS and from where I have to redirect them to their relevant sub directories keeping 301 redirect (SEO Friendly)

Appreciate your help, if anyone knows.

Was it helpful?

Solution

I found another way around for 301 redirects, it's like this:

  1. Put all your web domain to a single IIS Site. (the first Site) (e.g. www.domain.fr, www.domain.com.pk, www.domain.co.th, www.xyzdomain.com)

  2. Make another IIS Site for the main website (the second Site) (e.g. www.newdomain.com)

  3. Now put an asp / php / asp.net code for redirecting based on the conditions you have, in my case i used asp classic and put some code like this:

 
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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top