I have a client with 2 parts to their website. I do all of one part and act as the middleman for the second part. Now, the website I don't run is on IIS with ASP and we've had users mistype the urls for instance they'll enter http://mysite.com instead of http://www.mysite.com and http://www.mytown.mysite.com instead of http://mytown.mysite.com This is a 15 minute job to fix on a LAMP system but I accepted a 90 minute quote from the company... anything for peace. Well, 3 weeks later they are saying the job is done but... In the first example it only works with IE and not with firefox and it's a 302 and not a 301 redirect The second instance doesn't work at all. I've never heard of a rewrite being browser dependant - the reason given was that different browsers give different server headers. Well, sure they do, but the only header that matters is the requested url! Am I being unreasonable - is IIS really such a pig to work with? Any pointers I should be giving these guys?
There's a couple of ways to do this. You could grab the host header via ASP, like: <% strHost = Request.ServerVariables("SERVER_NAME") ' Redirect if no www If InStr(strHost, "www") = 0 Then Response.Clear() Response.Status = "301 Moved Permanently" Response.Redirect("http://www.newsite.com/") End If %> Code (markup): That method is by far easier. However, you could look into ISAPI_Rewrite for IIS, which even has a free light version that will turn a .conf file in your root into a file which acts similar to .htaccess in Apache.
have you installed isapi rewrite on the windows server? Lite edition should do, unless you want to use genuine htacces files under windows, than you should consider the pro edition.
They've got it working but throwing 302 so I've gone back and asked for 301's yet again. I don't have access to the server so I can't make changes myself.