Tag Archives: apache

Display all Apache configuration files

Various times I’ve had a problem with Apache and I’ve wanted to be able to display all of the configuration files as they are seen when parsed by Apache. As I can never remember now to do it I thought I would document it here.

The mod_info module can be used to do this. Just add the following to one of the hosts in your Apache configuration and then go to the /server-info address on your server.

SetHandler server-info
Order deny,allow
Deny from all
Allow from

Don’t forget to secure access to this location by IP address or other method (see deny and allow directives above).

‘mod_alias’ and ‘mod_rewrite’

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 nocache_XXXX_ where 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.

For example:
will be rewritten as
If the file.js changes we can modify the number in the url, which will force the browser to load the JavaScript again as it is a different URL, but the web server will return the current “file.js” inside the “js” directory, after the rewrite rule has been applied.

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.