Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I didn't have any luck finding anything useful on my own, so:

I would like to be able to automatically migrate all my .htaccess rules to the global Apache (2.2) config file, and disable .htaccess file parsing (for performance reasons).

That is:

  • after every code push a script would find all .htaccess files in a given directory (/var/webapps)
  • all the rules would be parsed and appropriately merged[1]
  • results would be written to Apache config file, and the server reloaded

I'm probably capable of writing this (or at least parts of this) myself, but I was wondering whether something well-tested already exists.

We have many different apps (incl. some 3rd party apps) running on the server, so doing this manually will greatly complicate the development-release process

[1] by merging I mean that, for example, all identical Deny from all rules would be in a single block, not duplicated dozens of times.

Or, is all this a really bad idea?

share|improve this question

Instead of re-inventing the wheel and adding additional complexity and another component that can fail by writing custom code for this, I'd recommend using configuration management software like Puppet or Chef.

Ditch the .htaccess files completely, store your entire Apache configuration in version control instead, and have that applied to your server by the configuration management software - maybe use a conf.d file with the rules that were formerly in the .htaccess files if you want to keep that isolated from other configuration.

share|improve this answer
Yes. But, as I said, we currently have many different (including 3rd-party) htaccess-enabled apps on the server. Moving them all to a unified version control model, with .htaccess files factored into separate config files, is rather unfeasible. – Joel L Feb 24 '13 at 0:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.