mod_rewrite is an Apache module that allows the server to automatically rewrite URLs on the fly. This very handy tool can interpret a URL request and rewrite it to any URL you like. Some common uses include:
- Replacing long ugly URLs with shorter, user-friendly ones.
- Preventing hotlinking, so other sites can't steal your bandwidth.
- Moving pages while keeping old links and search engine rankings intact.
What is mod rewrite not?
mod_rewrite is not the solution to everything. For instance, if your site is already well indexed in search engines, you should not convert everything to pretty URLs. Not only do you need to setup your new pretty URLs but you will also need to setup 301 redirects to preserve the old inlinks.
There is a lot this module can do, but it cannot do everything. Remember, your server will need to consider your rewriterules every time a request is made - that is for every image, every file and every page loaded, every time. It follows then that this may not always be the best solution.
Additionally, mod_rewrite can only rewrite requests - you must still update your scripts and pages to output the URL in your new rewritten format.