0

Rewriting URLs with mod_rewrite (Apache URL rewrite tool)

``The great thing about mod_rewrite is it gives you all the configurability and flexibility of Sendmail. The downside to mod_rewrite is that it gives you all the configurability and flexibility of Sendmail.''
-- Brian Behlendorf
Apache Group
`` Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo. ''
-- Brian Moore
[email protected]

The Apache module mod_rewrite is a killer one, i.e. it is a really sophisticated module which provides a powerful way to do URL manipulations. With it you can do nearly all types of URL manipulations you ever dreamed about. The price you have to pay is to accept complexity, because mod_rewrite's major drawback is that it is not easy to understand and use for the beginner. And even Apache experts sometimes discover new aspects where mod_rewrite can help.

In other words: With mod_rewrite you either shoot yourself in the foot the first time and never use it again or love it for the rest of your life because of its power.

Why use mod_rewrite

Hide original url and paths to scripts
Although obscurity is one of the lowest forms of security, you can use mod_rewrite to stop visitors seeing the full paths of your scripts. This includes the file extensions.
Tidy up URLs
Mod_rewrite allows you to take a hard to remember URL and tidy it up. The resulting URL can be something that the user can type out, rather that a really long mess.
Search Engine Optimisation
Search Engine will crawl your site with their bot scripts. Research shows that most Search Engines would prefer static pages rather than a Dynamic pages. 

For some examples on using mod_rewrite, see the Apache 1.3 URL Rewriting Guide

by 1.1K

Remember to vote! Voting helps everyone find the best posts

Tags: None