Changing a request URL or redirecting users to a different URL than the one they originally requested is done using mod_rewrite. This includes such things as:
- Changing HTTP to HTTPS (or the other way around)
- Changing a request to a page which no longer exist to a new replacement.
- Modifying a URL format (such as ?id=3433 to /id/3433 )
- Presenting a different page based on the browser, based on the referrer, based on anything possible under the moon and sun.
- Anything you want to mess around with URL
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask!
How can I become an expert at writing mod_rewrite rules?
- What is the fundamental format and structure of mod_rewrite rules?
- What form/flavor of regular expressions do I need to have a solid grasp of?
- What are the most common mistakes/pitfalls when writing rewrite rules?
- What is a good method for testing and verifying mod_rewrite rules?
- Are there SEO or performance implications of mod_rewrite rules I should be aware of?
- Are there common situations where mod_rewrite might seem like the right tool for the job but isn't?
- What are some common examples?
A place to test your rules
The htaccess tester web site is a great place to play around with your rules and test them. It even shows the debug output so you can see what matched and what did not.