.htaccess for beginners #2 - redirects

After explaining the basics of .htaccess files, in the second part of the .htaccess mini-series, we'll show two techniques of implementing redirects on your blog.

Technorati Tags: , ,

Whenever you're moving around contents on your blog, you should make sure that you don't leave nonworking links on external sites behind your actions. Most of the times a traditional redirect can solve the problem, so people going to the old URL will automatically go to the new one. This is the sample .htaccess line to use:

Redirect oldurl.html http://www.yourblog.com/newurl.html

Note that you can use any URL in the second parameter - even ones that are outside of your blog.

There is another option for redirecting, when the actual URL of the browsed document doesn't change, just the contents are being served from a different location. This is for example used in many blog engines to display user friendly URLs instead of long ones, full of ugly parameters.

However, the Apache Rewrite engine is a much larger topic to cover here in one blog post, so instead I provide a few URLs for reference:

As always, the best way to learn is to try. In case you happen to screw up your blog, just delete the buggy .htaccess file, reupload an old, working version from one of you backups (you do have a blog backup, don't you?), and try to debug locally.

April 04, 2006

Submit to del.icio.us | Digg | Furl | reddit | Y! MyWeb | comments (0)

Post a comment