Its not that unusual to need a large number of redirects in Apache, and even if you’ve been following best practice and keep sites in separate vhost files, a couple of rounds of redirects can leave your files bloated, messy and just that little bit more difficult to maintain.
The Apache RewriteMap directive allows you to create a ‘function’ which can then be called in RewriteCond and RewriteRule rules. Basically it means you don’t need to explicitly state each rule in your vhost files.
It works by allowing you to specify an external map once in your file using the following syntax:
RewriteMap mapname maptype:maplocation
mapname – being the the name you’ve given to your external mapfile [Read more…]