Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

[note: I asked this question on Stack Overflow, and it was suggested that I come here. I searched here and found this which is close to my question but not quite.]

We currently have a little over 450 rewrite rules in our Apache config spanning 4 different files. As you can imagine, they are vital to the way our site operates.

We of course check all the rules we add, have them in git, and ensure that they maintain the correct ordering so as to not step on each other's toes, but with a growing set of rules due to full-time development of the product, it's likely that this number will only increase.

What tools, and/or techniques do you use to maintain this vital (and potentially dangerous) configuration? What safeguards do you have to ensure that an improperly designed rewrite rule doesn't accidentally take out large portions of your site?

[The previous serverfault thread mentions RewriteMap, which seems like an interesting tool, but is not quite suitable for solving our particular problems.]

share|improve this question

2 Answers 2

What tools, and/or techniques do you use to maintain this vital (and potentially dangerous) configuration?

/usr/bin/vim

:)

What safeguards do you have to ensure that an improperly designed rewrite rule doesn't accidentally take out large portions of your site?

A proper dev/staging environment. Honestly, that's really going to be your only way to ensure that new rules don't whack things. Deploy there first, run through your testing procedures, and then deploy to prod.

share|improve this answer
    
I would like to also add, that excessive complexity of rewrite rules is usually a sign of poorly designed application or, inefficient rules themselves. If you don't have any choice, I recommend fragmenting the rules to multiple files in some logical manner and troubleshooting them one by one in a properly set up staging environment. And don't think that rewrite logging can help - with a large number of rewrite rules the logs quickly become a horrible unreadable mess. –  ExtraT Feb 28 '11 at 23:41
    
@ExtraT - I disagree. In an ideal world, that would certainly be true, but in a large site that has gone through many different iterations and several different structures, CMSes, etc., sometimes maintaining large numbers rewrite rules is a necessary evil for keeping the site in a decent state. –  EEAA Feb 28 '11 at 23:43
    
You are right, of course. But one can dream from time to time, right? :) –  ExtraT Feb 28 '11 at 23:48
    
@ExtraT of course. –  EEAA Feb 28 '11 at 23:48
    
Thanks for the response, but this is what we already do, but it's certainly harder than I feel is necessary. There's gotta be a better way. :) –  apgwoz Mar 1 '11 at 15:21

We are using svn + rsync + python script to sync all the rule files across the web farm. How do you use Git?

share|improve this answer
    
We make use of convention and symlinks. We'll checkout our source code or config to a standard location and symlink to files within it. We deploy using rsync from a single machine. –  apgwoz Mar 8 '11 at 11:17

Your Answer

 
discard

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.