Permanent 301 Redirect from http:// to http://www.

Hi,

How in dotNet or in the Control Panel can I put a permanent redirect from the http://domain.com to http://www.domain.com?

This really has to be done in code, as to Hsphere they are the same.

Thanks Steven.

Thought that might be the case … I will do some googling.

Hi all … having had a look around I cant find anything that quite suits the need so wondered if anybody here had a decent way of doing this?

I can obviously do this

:Response.Status = “301 Moved Permanently”
Response.AddHeader(“Location”, “/your-new-url/”)
Response.End()

But how do I check to see if they have come from www. or not?

Hi Stephen do you offer anything like ISAPI_Rewite from these guys?

ISAPI_Rewrite 3 - Apache .htaccess mod_rewrite compatible module for IIS

As that would make life real easy!!! :smiley:

Sorry but we don’t offer ISAPI_Rewite on shared server. You can install it on VPS server.

cheers manish

In a Global.asax file should Application_BeginRequest fire? Or is that somehow disabled?

that works fine, ISAPI addons are not installed due to a major way in which it makes logs have errors.

Cheers Steven. I found a good solution to work around so thanks.

I recently came across a solution where static websites on windows servers can essentially have a redirect for a non www domain to their www domain thats treated as a 301 redirect by the serach engines. I’m yet to test it but thought I’d share it here, I found it on Matt Cutts blog (google man)
just google ‘canonical links’

I figure its a good option for sites with no .htaccess file or the option to add additional headers server side. I’d be interested to know if anyone has tried this approach yet.

On another note does anybody know how to redirect default.aspx to the root ie.

http://www.testdomain.com/default.aspx to http://www.testdomain.com/ . I have tried interrogtating both

Request.ServerVariables(“URL”)
and
Request.RawUrl

and both always contain default.aspx so checking and redirecting causes and infinite loop??(

could I use the redirect part of hsphere??

In place of setting redirect on default.aspx, why don’t you add default.aspx as directory index ?