views:

134

answers:

3

I am rewriting some of sites in MVC.

I am concerned about old links out there, some I know about and some I don't.

I am looking for suggestions and code sample on how to make sure that my known and unknown links are not dead. What are your choices?

I would eventually like to phase out my old links. I hope to do this by notifying my users coming from old links about the new links.

I want to start off with something simple, as I am still learning MVC.

Another post suggested Managed Fusion URL Rewriter and Reverse Proxy.

A: 

Have a look at this article - http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

SUMMARY:Tip/Trick: Url Rewriting with ASP.NET.

http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx

SUMMARY:Blog - ASP.NET MVC Framework (Part 2): URL Routing.

adatapost
Please be aware that URL Routing is not URL Rewriting, URL Routing is for defining interfaces in to your application, URL Rewriting is for correcting URL's before they get to your application. What the OP wants is URL Rewriting.
Nick Berardi
@nick,Thanks for the comment. I know that I put that link for the reference.
adatapost
+3  A: 

I am the developer of the URL Rewriter you mentioned. If you would like help, please contact me as suggested in the ReadMe.txt file. What you are asking for is not out of the ordinary and can be easily accomplished using some very basic rules.

Well you brought up two important points. You want to notify your users about the new links, you biggest user your probably care about at this time is Google. You can address this concern with Google by doing a 301 Permanent Redirect. For example, this is how you would do it with the URL Rewriter syntax.

RewriteRule ^/(old-url.*)$    /new-url$1  [R=301]

The R=301 does the permanent redirect. The second your known and unknown links. For your known links you just need to map them to the correct part of your new application using the above rules. Depending on how many old url's you have you probably want to make the rewrite rule generic so one will catch many old url's.

For the unknown links you probably want to do one of two things, look over your server logs or analytics for anything important, and map those as appropriately to the correct part of your new code.

Then to make sure all the others don't totally go away you can redirect them to either your home page, internal site search, or just a generic page explaining that your site has been updated and this link is no longer in use.

Again please contact me with questions. The Managed Fusion URL Rewriter and Reverse Proxy will work perfectly with any .NET website (including MVC) on IIS 6 and any type of website on IIS 7 including PHP, Ruby, JSP, and Classic ASP.

Nick Berardi
A: 

If what you need is pretty URLs (or Search Engine Optimized), you can do it without rewriting your application. Check out URL Rewrite Module for IIS 7:

http://www.iis.net/extensions/URLRewrite/

It is Microsoft supported and supports URL rewriting and also response content rewriting (to fix your application links for example).

Daniel Vasquez Lopez.

Daniel Vasquez Lopez