Wednesday, February 09, 2005

Don't Forget the 301 Permanent Redirect

I was once involved with upgrading a web site that have a very deep structure and I wanted to flatten it out and organize it better. For example, in the old structure a product might have a URL such as:

In the new structure the URL was similar to:

This involved relocating several hundred pages and finding a way to let the search engines know the page had moved.

When the new site was ready to be uploaded, I put it online all at one time and changed the old pages to have a meta tag redirect. Thus if anyone went to an old page, they'd immediately be transferred to the new page.

A meta tag redirect uses HTTP-EQUIV to cause a different page to be loaded. It looks like:

meta equiv="Refresh" content="0; URL=/computers/accessories/zd85.html"

You can set the URL to any URL you wish, including pages on different web sites.

This was great, and it was working fine. Visitors were ending up on the correct pages. But, I had forgotten something.

Search engines handle the HTTP-EQUIV with varying degrees of success. In most cases they go to the new page, cache the content of the new page, but assign the old URL to it. Thus the old URLs continue to show up in the search results. That's not what I wanted. Part of the reason for the change was to make the URLs more relevant and easier to read in search results.

What I had forgotten was to put in permanent redirects. A permanent redirect is done differently on UNIX and Windows systems. If your web site is hosted on a UNIX system, the permanent redirect goes in the .htaccess file and is called a 301 redirect. What's that, you ask?

The .htaccess file is a plain text file, located in the root directory. It can also be located in other folders, but I'll leave that for another article. To add a permanent redirect, a line of text such as the following is included:

Redirect 301 /oldpage.htm

There are three parts to the above:

"Redirect 301" - this tells any computer that reads this file, such as the Google spider, that this file has been permanently moved. It also tells the hosting computer that anyone who tries to access the specified page should be sent directly to a different page.

"/oldpage.html" - this specifies the page that has been relocated. The identification of this page always starts in the root folder, thus it always starts with a backslash, followed by the appropriate folder and file names.

"" - this specifies the full URL of the new page. It always starts with "http:" and includes the full path to where the new page is located.

For web sites hosted on Windows you'll need to have the system administrator set up the permanent redirect through IIS.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home