301 Redirects and Custom Error Pages

The .htaccess file has a variety of purposes and all SEO’s should have a basic knowledge of these. In this post I’m going to tell you how to create an .htaccess file and how to setup two of the most frequently used .htaccess features – 301 redirects and custom 404 error pages.

Creating an .htaccess file

Firstly, a few points about the .htaccess file:

• The .htaccess file is a plain text file which should be created using Notepad or Simple Text.
• Each instruction should appear on its own line.
• You will need to save the file as .htaccess. (The file name can be quite confusing as it appears to look like a file extension. It is NOT an extension and the biggest mistake that most people make is not adding the full stop at the start.)
• You may need to manually rename the file after you create it as Notepad will only allow you to save files as “something.txt”.
• The file should be uploaded to your sites route directory.

301 Redirects

As most of you will probably know, when you change the URL of a page all of the PageRank, search engine positions, bookmarks and in-bound links that the page has established will be lost or broken. The 301 redirect is the only type of re-direct which will successfully solve this problem.

A 301 redirect has a very specific job. It tells the search engines that you have permanently moved a page to a new URL and it is essential when you’ve changed things such as page name, domain name, site sub folders or file extension.

The .htaccess code for a 301 redirect is very simple:

redirect 301 /old/old.htm http://www.url.com/new.htm

Although this code is very simple I’ll break it down for you. Firstly you need to specify that it’s a “redirect 301”, leave a space, write the old URL (which should be relative), leave a space, write the absolute URL of the new page and that’s it!

A 404 Page Not Found Error Page

I’m sure many of you have seen the “The page cannot be found” page which appears when you type a URL in wrong or there is an error in a sites navigation. This page is usually a standard IE, Fire Fox or server page.

Using .htaccess we can create our own “The page cannot be found” page which appears when visitors make mistakes in their navigation. The custom page will also appear if you have made any mistakes with your site navigation or programming.

The benefit of a custom error page is that it has all the features/menu etc of your site. This is beneficial as it reduces the chances of your visitor leaving, if you have an e-commerce site you may still be able to keep the sale and it looks good!

The code that you need to add to your .htaccess file is:

ErrorDocument 404 /directory/my_error_page.html

Although it looks simple, I’ll break it down again. Firstly you write “ErrorDocument 404” which tells the browser that every time a 404 error occurs it needs to re-direct the user to your specially created error page. Leave a SINGLE SPACE then give the relative location of your error page. Easy peasy!

More uses of .htaccess to come!

Tags: .htaccess, Custom Error Pages

Leave a Reply

Follow us on Twitter™

This site will not know or use the details provided here by you.

One of 567 websites proudly supporting Earth Hour. On WordPress? Get the plugin.