I am using asp.net 3.5 and IIS 6.
How can we automatically redirect pages from http(s)://example.com/*
to http(s)://www.example.com/*
?
thanks.
I am using asp.net 3.5 and IIS 6.
How can we automatically redirect pages from http(s)://example.com/*
to http(s)://www.example.com/*
?
thanks.
I think that's best done with DNS.
I did this with an HttpModule:
Then we need to add the module to our Web.Config:
Find the section
<httpModules>
in the<system.web>
section, it may well have a couple of other entries in there already, and add something like:You can see this in action here:
All end up on http://www.doodle.co.uk
In general, the performance will be better if you let IIS handle the redirection. To do that, create a new web site with the host header set to example.com, and use IIS Manager to configure the redirection.
This MSDN page might help you.