Those of us who use apache on a daily basis often have to modify the apache conf file, but I am sure, like myself, we don’t even use half of the directives available. For a full list you can check them out here:


One interesting one I have started using is LocationMatch. This basically allows you to create an if statement in the virtualhost.

The first time I needed to do this was to ignore a mod security rule for a single file that was 3rd party code and was being blocked by mod security.

I didn’t want to disable the rule entirely so I used this basic rule

If file ==file
ignore rule

or in apache

<LocationMatch “[filename]”>
SecRuleRemoveById [rule id]

restart apache and now that rule will be ignored for that one file.

On top of this you can use regex for the match so you can build one rule that will catch multiple file names.

And after matching the file you can pretty much apply anything that apache can do without affecting the rest of the virtualhost.

One advantage to this is that you can do things which would normally be put into htaccess files. This keeps your special configuration all within the apache conf to make trouble shooting easier at a later date (how often have you found yourself trawling through directories looking for htaccess files), meaning that new people to a project only need to check the virtual host instead of hunting for other changes in the directory structure.

Anyway, I am sure other folks will have better ideas than me on how to use this as I am still coming up with useful tweeks on this one!

This entry was posted in Managed Hosting. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>