Isn't 301 Redirection too simple to talk about here?

I would say "yes" other than the fact that most web designers don't realize that there really is a good reason to use 301 redirects.

I started using 301 redirects when I changed the layout of this very page on disk. It seemed to me that it would be simpler and cleaner for my end-users to only see the directory for the subject they were interested in instead of having the URL include whatever.shtml.

When I first did the switch, I lost a good chunk of traffic and got a whole bunch of 404 errors in my logs. This was simply because the rest of the world (and most importantly, the search engines) only knew about the old format. The solution to this problem is redirects. Redirects both automatically move your end user over to the new correct page and tells any automated system crawling your page that the location of that particular content has changed. This gives the crawler a chance to update its database.

Maybe this isn't a terrible idea. How do I do it?

There are a couple of way to do redirects:

Put it in the source

To redirect in the page source, you have to add an "http-equiv" meta tag to the header of the page you want redirected. In this example, a flat page is redirected to a perl script.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="refresh" content="0;url=/cgi-bin/index.pl"> <title>Index Redirect</title> <body> </body> </head> </html>

The main problem with this style is that you have to keep files around in the old locations to do the redirect. In my opinion, this pretty much defeats the purpose of doing the redirect. This problem is solved in the next method.

Let Apache do the thinking

Apache allows user access to be defined on a case by case basis. This is accomplished through the use of .htaccess files. Apache's Tutorial covers very well when and how to use .htaccess files, so I'm not going to go into that here. Basically, you need to put something like the following into a .htaccess in the root directory of wherever you will be redirecting from.

redirect 301 /motov400.shtml http://www.wolfteck.com/motov400/ redirect 301 /vprmatrix220a5.shtml http://www.wolfteck.com/vprmatrix220a5/ redirect 301 /ze4200.shtml http://www.wolfteck.com/ze4200/

This sets up the redirection of three of my old pages to their current locations.

Well, that was easy

Yes, it was. And now you know.

Last updated: Sunday, 20-Sep-2009 16:55:49 CDT

Contact me at randall dot will at gmail dot com

Hobbies

Vintage Motorcycles

Networking

Facebook
LinkedIn

Presence

Ubuntu
Discount ASP.NET
CPAN
p2p Wrox
Roundcube
Freshmeat
Blogger
uShip
Psychology Software Tools
Virtual Corvair Club
Chopper Charles
Live Journal

Thoughts

Borrowed Philosophy
Historical Histrionics
Current Histrionics

Old Projects

Motorola V400 / Linux
HP ZE4200 / Linux
VPR Matrix 220a5 / Linux
FreeRadius Accounting / Linux
LDAP / FreeRadius Auth / Linux
Remote MySQL / OSX
Stewie Radio Automation
Wireless Wandering Done Right
DynDNS: TinyDNS / OpenSSH
Xilinx WebPACK 6.3 / Wine
Xilinx WebPACK 7.1 / Debian
Apache 301 Redirection
Using Your Debian Cache
Google AdSense
Gnome AdSense Monitor
Pixlatch Gallery Generator
C#.NET Tips & Tricks
Ubuntu Breezy Clockmod Bug