views:

574

answers:

3

Hi

I have an existing site in php running on Apache using the mod_rewrite plug-in. In other words, I currently have urls like www.example.com/section/subsection/ which Google and others have indexed.

However, the site needs a major upgrade, and I would like to move it to asp.net. I only have the option of using a shared hosting solution (iis 6, aps.net 3.5, full trust). So my question: How do I make asp.net do a 301 redirect from my old urls like www.example.com/section/subsection/ to their equivalent ones on the new asp.net site?

I obviously needs this to not loose the current rankings in the search engines.

Thanks, Egil.

+1  A: 

If you use the ASP.NET MVC framework it has a URL rewriting system built into it.

You can manually add 301 redirects into IIS using IIS Manager if you want to set up "moved" locations.

If you want to do URL re-writing then you will need to implement IHttpModule, hook up the BeginRequest event, and add that new class to the httpModules section in Web.config.

Paul
I cant add 301 redirects directly into IIS since I am on a shared host. Also, would IHttpModule or asp.net mvc work with urls that do not end on .aspx? If I am not mistaking, IIS will not redirect a request to the asp.net engine unless it is for a page with the .aspx extension.
Egil Hansen
In IIS6 you can set all requests to be passed to the asp.net plugin regardless of extension. This can be set up on a per site basis in IIS Manager, so there is no reason I can see why they wouldn't enable this it if you asked them.I believe this is fixed in IIS7 and can be set in Web.config.
Paul
OK. That is an option. The thing is, asp.net is not nearly as efficient as IIS when it comes to serving up static files, so it will be a last resort. Thanks.
Egil Hansen
A: 

According to Steve Sanderson’s blog post Deploying ASP.NET MVC to IIS 6 it do not look like there is an option to do url rewriting/redirection with IIS6 in a shared hosting set up, where you cant manually configure IIS. Gah...

Egil Hansen
+1  A: 

Okay...so this may be overkill and could possibly be done another way in two lines..BUT...

If you are keeping the same domain name then what I've done in the past is keep a table of old urls and how they map to new urls. On the application's request, I'll scan the table, if an old url is found then I'll add a header that does a 301 redirect to the new URL.

domus.vita
The thing is, the old urls are not "asp.net" urls, in other words, the asp.net runtime never gets to process them, so that is not an option for me I am afraid, thanks for the input though.
Egil Hansen
But even on a shared host you should be able to add a custom 404 handler for non-ASP.NET content - this would be configured in your domain control panel type area. This should be an .ASPX page that looks at the requested page (which is passed to you via IIS), and then perform your lookup.
Zhaph - Ben Duguid