Implementing 301 Redirects on Legacy URLs

March 4, 2009

The implementation of 301 redirects for legacy URLs is a crucial step in website redevelopment and URL optimization projects. It seems that web development companies that are not strong in Digital Marketing often make the mistake, out of ignorance more than anything, of not properly taking care of legacy URLs, that is of URLs that used to rank on the previous website version but whose content has been assigned a new URL.

For example if the details page of a product is now on the legacy URL prior to the website redevelopment or URL optimization could have been


What would happen if Google continued to send traffic to the legacy URL?

The worst outcome would be a dreadful 404 error message back from the server. That product page, which used to rank for Google, now only provides your visitors with a sad “Page Not Found” message. If you are seeking to preserve some of your rankings after the launch of your new site version, a 404 error is unacceptable. We have seen in the past that web development companies will at least gracefully handle a 404 by redirecting the user to the home page. Your old rankings will likely still quickly dwindle, but at least you are not faced with the user experience disaster of a 404.


We come now to what should be done to properly address legacy URLs. The answer is simple. Create URL Rewriting rules to instruct your server to return 301 messages instead of 404 messages for those URLs. A 301 is a “Permanent Redirect” message that conveniently provides a new URL and instructs your visitor’s web browser to go there instead.

But you have dozens, hundreds, even thousands of products. It sounds a little crazy to produce rewrite rules for all URLs, and in fact it is crazy. In many cases you don’t have to. That’s what the rewrite engine and regular expressions are for.

Assuming that you use ISAPI Rewrite 2 using the example above you can accomplish all of your product detail redirects with one rule:

RewriteRule /product.asp\?productCategory=(.*)&productName=(.*)    /Products/$1/$2\.html [I,RP,L]

In the first half of the rule each parenthesis block creates a back-referenced subexpression. Two back-referenced subexpressions are created, one after the productCategory equal sign and one after the productName equal sign. These subexpressions are then “back-referenced” on the second half of the rule as $1 and $2 respectively and so this rule tells the server:

  1. If there is a request for anything in the format /product.asp?productCategory=[Back Reference Subexpression #1]&productName=[Back Reference Subexpression #2]

  2. Apply this rule in “case insensitive” mode so it does not matter what was lower case or uppercase in the requested URL (thus the “I” flag at the end of the rule to indicate Case “Insensitive”)

  3. Produce a permanent redirect (thus the RP flag at the end of the rule to indicate to “Redirect Permanently”) and tell the visitor’s browser to go to /Products/[Back Reference Subexpression #1]/[Back Reference Subexpression #2].html instead

  4. If there was a match, make this the “last” rule that applies and do not continue down the rules file looking for other rules (thus the L flag at the end of the rule to indicate that this is the “Last” rule)

This will also tell the search engine spiders that a page has been permanently redirected and eventually it will know that the page that used to be located at the legacy URL now has a new URL.

301 Redirects for Legacy URLs should not be an eleventh hour implementation process. To be effective it needs to be properly thought out at the beginning of a redevelopment or URL optimization project. The example above assumes a best case scenario where your legacy URL contain all of the information that your new URL needs. I will discuss conditional expressions and rule loops in a future post to address more complex scenarios.

Did you like this post?

Sign up for our Tips and Trends list and we'll let you know each week when we have a new one.

Click Here For Your 14-day FREE Trial


Web Design (26)
Web Development (35)
Misc. Website (21)
Search Engine Optimization (95)
Social Media Marketing (111)
Local Search Marketing (24)
Content Marketing (34)
PPC Advertising (31)
Digital Marketing (123)
Marketing Automation (23)
Sales Automation (17)
Company News (10)
Other (27)



Related Posts


Response to: Implementing 301 Redirects on Legacy URLs
Wednesday, March 4, 2009
Brent says:

You're giving away all your secrets!