Search Engine Friendly Redirects – Custom 404s
There are three articles dealing with redirects to handle, see related posts for more information.
If you are going to move a page you will likely want to redirect visitors from the old page to the new in such a method that the search engines don’t get confused. Some of the ways they can get confused include:
- Bringing up two copies of the same page. This is likely to trip a duplicate content penalty.
- Using a temporary redirect. This means ‘the page has moved but will be back shortly – don’t update your index’.
A 301 permanent redirect is the redirection method recommended by the major search engines. Using a 301 redirect you are in effect telling the search engines the page has moved and to update their index. It also has the nice side benefit of redirecting the benefit of inbound links to the new page.
Detailed below is how to use a custom 404 redirect to handle moving pages. A 404 error is produced when the server can not find the file requested by a visitor. This is useful if you can’t use the normal 301 redirect methods, such as when you move CMS systems, the whole of your site’s file layout changes,etc. I have used these techniques when switching from static .htm pages to dynamic .asp pages which necessitated changing all filenames. You can also use this method to make the redirects database driven.
These 404 based redirection techniques rely on programming. When set up you will need to check that the server has overridden the 404 error code with a 301 code using a header checking tool (there are plenty available on the net).
IIS 404 Redirect
Using the IIS MMC as follows:
- Right click on the website or directory that you want the 404 to apply to.
- Click ‘Properties’.
- Click on ‘Custom Errors’
- Scroll down to 404 and highlight. Click the ‘Edit’ button.
- In the drop down, select URL (this is important – doesn’t work otherwise). Then enter a URL on your site to use for the programming.
- Click ‘OK’ to save this change.
On the custom 404 page itself you can use vbscript or any other programming language to read the server variables to decide what page to display, or where to redirect the user.
Apache 404 Redirect
Create a file called .htaccess in your root directory and add the following line:
On the custom 404 page itself you can use PHP or any other programming language to read the server variables to decide what page to display, or where to redirect the user.