Apache mod rewrite to redirect

We are often asked to do web site redesigns. Most of the time the goal is to optimize the existing site for search engine rank and visitor conversion. While it is tempting to just throw away the existing site and start over, many times there are ways that we can use what is working from the site to our advantage.

One of the biggest parts of the site that can usually be salvaged is the existing search engine position for pages of the site that bring in traffic. The first step is to look at a 30-90 day web stats program that shows you the top entry pages of your site. We use an excellent open source program called Awstats for all our hosting clients. 

The entry page report shows the pages that visitors come to FIRST on your site. Most sites will list "/" as the top entry page. That is your home page. We don't have to worry about salvaging this page because we will have a page with the same name (index.html or index.php or ??) on the new site.

However, what if we look at the entry page report and we see 50 people landing on a page named index6.html which is a big content page on, for instance, where to buy baseball bats in San Diego. Ideally we would want to name that page something like buy-baseball-bats-in-san-diego.html which would be much better for SEO. 

Well what happens if we just change the name of the page? Those 50 people a month suddenly get a "Page not found" error when they come to the site for the first time. How many do you think will give your site a second chance?

Enter Apache ModRewrite!

With just a little code like this…

RewriteEngine On
redirect 301 /index6.html http://www.mywebsite.com/buy-baseball-bats-in-san-diego.html

we can automatically redirect visitors asking for our old page name to our new page name without the visitor knowing anything has happened. Even better search engines will automatically update their search engine listings to include the new page name.

You only need the RewriteEngine On line once. Then one line for every page you want to redirect. You should leave the .htaccess file in the same folder as the home page of your site. 

By recycling page names with Apache ModRewrite you are able to more rapidly increase your search engine rank for the most important pages of your site.

For more information on Apache ModRewrite see this page.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.