We recently went through a major site redesign for an IIS 8, C# web site.
We have around 2 to 3 hundred old pages which needs to be redirected to new pages. All of them needs to be 301 redirects for SEO.
We are looking for some best practices to do this, without maintaining the physical files on the server.
2
Answers
Maintain a database of those URLS, that can be eventually loaded into memory at startup.
The 404 handler checks if the page exists in that database, and performs the redirect.
I don’t know any solution for this… In sitecore or Umbraco there are some plugins to do this by example.
But it works great… If the old URL is replaced, then it will not be handled.
And you could extend that system even later, to maintain a database of all the urls invoked on your website … Array of References (For Each Path Item): Url + Current URl, if for some reason you rename an item, then you can update your database with all URLS that contain some item.
IIS and .Net have several ways to do redirects.
In the code handing the request:
In the web.config file (probably the easiest way for you):
It accepts regex so you can optimism this if the redirects have a pattern.
Finally you can take full control at a base level via the Routing Module (System.Web.Routing.UrlRoutingModule) and your own IRouteHandler.