I spent a few hours recently trying to debug some Apache Rewrite rules on our development server.
We had a particular directory outside the root of the website that I was using an Alias command to make available. However, within this directory I also wanted to apply a couple of different Rewrite rules.
A simple cachebuster
One of the rules was basically to remove instances of the string
XXXX was a number which could change (this is usually a date-stamp, such as 20130131 if modified on 31st Jan, 2013). This allows us to easily change the number in the URL which will force the browser to reload the page, avoiding possible caching problems.
will be rewritten as
To cut a long story short, I found out that mod_alias and mod_rewrite cannot be used together. Therefore, the workaround in my case was to use just mod_rewrite and use a symbolic link instead of trying to use mod_alias. Note that to allow symlinks to be use, it is also necessary to specify
Options FollowSymLinks within the Apache config for that site.
Maybe this will help someone else avoid wasting time trying to get mod_rewrite to work on top of mod_alias.