Apache’s rewrite engine is very powerful and often misunderstood. It can be fairly cryptic to work with and given that a mistake can take down your site it can be costly to debug. While I’ve tested the following rules thoroughly I’d recommend testing them yourself on a non-live site prior to putting into production.
Before using the following bits of code please make sure that you have rewrites enabled by using:
This can be put in either a .htaccess file or in your virtual hosting configuration location. Read more