Today I eventually started optimizing the performance (thereby reducing server load a bit). It appeared some pages of my larger websites have grown to round about 300 kb causing some latency for lower bandwidth visitor. Having a quite good connection myself, I didn't care about that much in the past. But that's ab pity, because it is very simple to add compression to pure PHP-generated content.
Redirecting whole websites or single webpages with mod_rewrite is a very important feature when doing search engine optimization (SEO) or when moving from one webserver or domain to another.
Redirection is usually done with a small block of code that is added to an .htaccess file in your websites root path. The code snippet looks like:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
It is often misunderstood and the bulletin boards have hundrets of incomplete or wrong assumptions about Apache and mod_rewrite. That's why I decided to write an article about it.