Mass 301 redirects in ASP.NET, including pages that need to redirect to a different place depending on the query string parameters

StackOverflow https://stackoverflow.com/questions/1440883

Question

We have several pages of our site indexed using old non-SEO friendly URLS such as http://www.domain.com/DocumentDetails.aspx?id=555. Recently we implemented routing that uses slugs stored in the database and looks up the slug to forward you to the right page using routing, for example: http://www.domain.com/Documents/Title-of-the-Document

This is all well and good however we are having a hard time finding the best way to set up our 301 permanent redirects for all the links currently indexed by Google.

Is there a way to have 1 centralized place to store old URL and new URL, and have it do the 301 redirect automatically when it finds an entry, and also treat different query string parameters as different entries? We are using IIS6 and Server 2003.

Thanks!

Was it helpful?

Solution

Add a CustomRouteHandler for your old page that can do the 301 to your new URL:

//look up new url and do the 301
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com/"); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top