My stats program gives me a list of 404 errors so I can easily see what pages are giving an error and I just add one line to my .htaccess to redirect the visitors to the correct page.

The other day, I noticed in my 404 stats that there was a lot of traffic from a domain forum going to a page that did not exist on my site. The visitors were presented with my custom error page letting them know about the error and then suggesting that they view the Sitemap.

I noticed that many visitors were just leaving my site after they viewed the custom error page.

Here is what I did to fix the problem and improve the visitor experience.

The solution

I noticed in my server logs that the page /**********com-sale-was-a-bargain was being accessed but since the page did not exist my server would give a 404 error page.

The real page that the visitors were looking for is called /domaintalkcom-sale-was-a-bargain

So what I did was open my .htaccess file on the site and added the following line (put this all on one line):

Redirect 301 /**********com-sale-was-a-bargain http://toomanysecrets.com/domaintalkcom-sale-was-a-bargain

What this does is tell the web server that when someone accesses the old page, redirect the visitor to the correct page. To the user, the redirect is seamless and they get what they were looking for without getting any error pages.

Click here to test my redirect. Try it and you will see that it redirects you to the new page with no more errors.

Enjoy!

Share

2 Responses to “Redirect lost traffic with one line of code”

  1. How does a person using a mac create and modify a .htaccess file? Macs do not allow any document to be created or modified if it begins with a “.”

    :-)

  2. Richard says:

    Elliot,

    Just make a file called htaccess or any other name you wish on your Mac, then modify it and upload it to your web space. Once you have it in your web space root, rename it to .htaccess.

    Also note that you need to have the mod_rewrite apache module installed for the Redirect to work - most hosting companies install the module as part of the basic account setup.

    - Richard