Leaving a Forwarding Trail with a Permanent Redirect
Permanent redirects can be very useful when removing a page from your website or changing a page name. Without a redirect, visitors may end up seeing a “Not Found” error when they try to visit an old link. This can happen when a page has been deleted, renamed, moved, or replaced with newer content.
There are several ways to handle this problem. Many older methods involve leaving a file on the server with the same filename as the old page. That file usually contains code that sends the visitor to the new page or to another relevant page. While this can work, it can also make site management messy if too many redirect files are scattered throughout your website.
Is there a better way you may ask. Of course! At Truecast there always is. Ok most of the time there is or if there isn’t, we’ll find one. So what is the solution to your orphaned file woes? The .htaccess file again. For those of us fortunate enough to have a Unix/Apache web server, there is a better way. Visit Redirects and Other Timed Responses for more information on why a permanent redirect is the best solution.
Permanent redirects (error 301) are a way to telling the web server directly that a page is no longer available at an address and can now be found elsewhere. The good thing is that it doesn’t need the old file around to do it’s trick. And it’s very easy to do for those of you that are web challenged.
The hard part of this is finding and making sure you have an .htaccess file in the top level of your web directory. I will write an article later about how to create one or find it on your site.
An any case, download it from your site and edit it in your favorite text editor. For each redirect that you want to make, type or paste in this line of code and edit the urls in it.
redirectpermanent /file.html http://www.yourdomain.com/newfile.html
After you are finished, save the file and upload it back to the server. Try and access the page you just redirected and it should now auto take you to the new address. That’s it, your done. You can keeping adding new forwards to your site by adding them to that file and you can delete the old files from your server.
Written January, 2005 © Truecast Design Studio. Author: Daniel N. Baldwin.