Apache Redirect Directive
published 01.Jan.2002
You have the following problem
You have a document that has been on your web site for several months or even years, which is registered with all of the major search engines, and for whatever reason you need to move the physical location of the file or rename it. This will result in lots of 404 errors, as people still access your page from the search engines, or from external sites which still link to the old URL for the document.
The Solution : Apache Redirect Directive
The Apache Redirect directive allows you to tell clients and browsers about documents which used to exist in one place but have since moved. This allows you to tell the clients and browsers where to look for the relocated document.
Format:
redirect status oldURI newURL
The redirect commands need to be entered in the <virtualhost> block within Apache's main configuration file httpd.conf. If you do not have access to your servers configuration file, then contact your ISP's support desk.
Example Virtual Host Block
During 2008 I transferred my articles from the business web site, to this site. Many of these pages where already registered in Google, and some users had the pages booked marked, so I set-up redirects to their new location here at base64.co.uk
Below is the code being used to redirect this article from is old location to here.
redirect 301 /apache_redirect_directive.html +
http://www.base64.co.uk/apache-redirect-directive/
Note: The + character is used above to indicate a line break, it should not be included in a live redirect command.
As you can see from the above example I am redirecting visitors from the old page name apache_redirect_directive.html and pointing them to the new page here at http://www.base64.co.uk/apache-redirect-directive/. It's worth pointing out, that the newURL does not have to be the same filename, so I have taken this opportunity to tidy up the URL's when moving the files.
HTTP Status Codes
In the above example I am using a status code of 301 which lets search engines know that this is a permanent document move, and that they should remove the old reference.
Other status codes you may want to use include 410, which lets the search engines know that the content has gone completely.
