I have a website under IIS7 with catch all subdomain as *.mydomain.com
but some sites randomize subdomains like:
- www2.mydomain.com
- w.w.w.mydomain.com
- etc.mydomain.com
Any subdomain works perfectly loading my MVC page, but the google indexing doubles the url, because have two url differents.
I would redirect permanently “301” any subdomain to http://www.mydomain.com using global.asax keeping the url and query string. e.g.
-
www2.mydomain.com/Controller/Action/ID?query=asb TO
http://www.mydomain.com/Controller/Action/ID?query=asb -
w.w.w.mydomain.com/Controller/Action/ID?query=asb TO http://www.mydomain.com/Controller/Action/ID?query=asb
I want not to use IIS7 redirect because I will customize with C# the what subdomains should not be redirected.
I don´t like to create page base for all controller.
Assuming you are using IIS, you should be able to achieve this with ARR.
Example:
Reference: http://forums.iis.net/p/1155754/1895646.aspx