Take Heed of Path Prefixes when 301 Redirecting

Beacon Blog Article

By Beacon News | Published April 22, 2011 | Categories: SEO

When restructuring a site's URLs, the proper use of 301 redirects can make or break the continuous flow of traffic without a significant drop-off. Not only will this ensure that any traffic intended for the previous page will reach the most appropriate new destination, but it will also pass Google PageRank of the previous page to the new one. This makes it much easier to build or maintain search engine rankings than trying to build a new page up from scratch.

301 redirecting through an .htaccess server file is a pretty straightforward process. The line of code for a redirect can be as simple as:

Redirect 301 /site/original-destination.html /page/new-destination.html

For pages that end with a file extension, it is just about as simple as that. However, many systems nowadays will actually drop the file extension from the name. For example, /site/original-destination.html will actually appear as site/original-destination. This is a subtle, but important difference when it comes to redirects. It may not be wise to use:

Redirect 301 /site/orginal-destination /site/new-destination

This is because the standard 301 redirect is actually path prefix redirect, meaning that not only will /site/original-destination get moved to the new page, but so will /site/original-destination-A, /site/original-destination-2, /site/original-destination-iii, etc. Any page that begins with the redirected term will get moved. If you are moving an entire directory, this is a good thing. However, if just a single page or smaller group of pages needs to be moved, this is too broad a brush and can lead to problems.

The solution lies in using regular expressions with the RedirectMatch phrase. Use the carrot (^) to match the beginning of a string and a dollar sign ($) to indicate the end of the string. This will ensure that only the page designated is redirected:

RedirectMatch 301 ^/site/original-destination$ /site/new-destination

Note: As different systems have their own variations on how to handle redirecting, make sure to have an understanding of the syntax and redirect/rewrite rules in play before implementing this.

Follow me on twitter: @ejwestksu

Let's get to work!

Contact Us