Reputation: 9857
There is an ASP.NET 2.0 web site that I intend to migrate to a new web framework based on ASP.NET 4.0. While I know this involves manually preparing a script/program to transform site's content from old application's database schema to the new one, I am more concerned about preserving the old URL formats; mapping them to the new web engine's URL format.
I have not yet decided what is the most appropriate CMS engine to migrate towards (thus Web forms or MVC is still not clear). However, I'd like to draw on everybody's experience on
Google Analytics is already configured for the web site, so there is a history of the most requested links to study - which are the most important URL formats to remap and which are not worth preserving.
Due to work areas i've been diverted to the past few years, I've not been able to keep up with the latest ASP.NET capabilities that can help with this. Oddly, I find little material discussing how to properly preserve old URLs; most web sites are pretty nasty in totally discarding their old links when they perform a design overhaul.
My first thought of the most straightforward technique is just to specify in web.config a custom 404 aspx page that will read the old requested URL (which will carry the original content ID). Based on the content ID, look up a custom database table to find the new content ID, and redirect with the new URL.
At this point I am unsure if I'd want to make use of URL rewriting HttpModule or extension because I'd only want to incur the "lookup" only when it becomes 404, rather than a check on each and every request. Knowing that old URL requests will eventually fade over time.
What other factors/aspects should I consider?
Upvotes: 1
Views: 481
Reputation: 61599
For SEO performance, it's not really a good idea to issue a 404 or a 302 if you want to maintain good link value for each page you should issue a 301, a permanent redirect which search engines will use to pass any link equity to the new url.
With MVC you could register your old urls to a route that uses some form of dedicated RedirectController
, something like:
public class RedirectController : Controller
{
public ActionResult RedirectArticle(int articleId)
{
string newUrl = // do something to figure out the new url, e.g. http://localhost/article/1 -> http://localhost/1/my-custom-article-url
return RedirectPermanent(newUrl);
}
}
That way, you can register routes to support both the old infrastructure and the new, with a RedirectController
issuing the appropriate page-specific 301 redirect to the new page.
routes.MapRoute(
"NewArticleUrl",
"/{articleId}/{articleTitle}",
new { controller = "Article", action = "Display");
routes.MapRoute(
"OldArticleUrl",
"/article/{articleId}.aspx",
new { controller = "Redirect", action = "RedirectArtciel" });
Upvotes: 1