We have asp.net mvc 2 site which allows www and without any subdomain. For consistency we want to redirect any www request to without any subdomain.
Just like stackoverflow does.
Where and how it should be done? using asp.net Requestrouting?
Also i want it for all request to the site not just for home
I use URL Rewrite for this. You can download/install here: IIS Url Rewrite
After installing that to to IIS, select the website you want to create the rule for and then click the URL Rewrite module icon.
Click the “Add Rule” link in the top right corner.
Select “Canonical Domain Name” from the premade rules in the dialog box that pops up.
From there select the non-www option.
This tool adds a rule to your web.config file. URL Rewrite must be installed on the webserver you deploy your app to in order for the rules to work.
This is just the tip of the iceberg of what the tool can do. I find myself using it all the time. Here is a brief tutorial about using it: learn.iis.net/page.aspx/460/using-the-url-rewrite-module/
(just add http:// before that link above)
(I’m new so I only get one hyperlink…aboo)