gnumatt

I'm impressed with Apache's mod_rewrite.

I’m impressed with Apache’s mod_rewrite. I was able to vastly simplify how I redirect people from one web server to another by modifying the Mass Virtual Hosting recipe in the mod_rewrite guide. Now I can redirect something like dallasmoviegeek.com to a new url by just adding one line to a text file.

Just a little thing, but it sure did cheer me up.

If you are curious how I do it then here you go. I made a file called rhost.map that has lines like

www.dallasmoviegeek.com http://web2.airmail.net/a0004950

Then I put this in my apache config to handle redirecting folks.> RewriteEngine on RewriteLogLevel 0

RewriteMap lowercase int:tolower RewriteMap rhost txt:/usr/local/etc/apache/rhost.map

RewriteCond %{HTTP_HOST} !^$ RewriteCond ${lowercase:%{HTTP_HOST}|NONE} ^(.+)$ RewriteCond ${rhost:%1|http://www.amplify.com} ^(.)$ RewriteRule ^/(.)$ %1/$1 [R=permanent]

Voila now I just update that text file to redirect domains. No config file editing. No restarts. If they somehow made it to my server and I have no idea where they want to go then it falls back to amplify.com.