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

How would you go about cleaning up a huge list of rewrites that accumulated over many years? The idea is to get rid of all the overridden and unused redirect statements while preserving everything that works.

I am thinking of enabling RewriteLog and setting RewriteLogLevel to 3 or 4 for a day or so, then parsing through the log and identifying "dead" rewrites, commenting them out, then checking the logs for fresh 404s.

Have you had to do a mod_rewrite cleanup like that and/or do you have any other ideas?

share|improve this question
Favorited, I have some old rewrites but can't think of a better way to clean them up besides some long, hard work! :) – Dave Drager Dec 11 '09 at 18:34

The difficulty in this task is multifold; if they're not commented then you have to reverse engineer them into some common English and get other people to help answer "does anyone know why this is here?" type of issues. Some of these rewrites may also be linked to from outside (think a blog or forum post somewhere) that people still use -- I have one link that's on a forum from years ago that people still find with Google and use to get to the content, so I can't really get rid of it.

Your best solution is to do some log monitoring/parsing (I like AWstats) over a period of time and see what requests are actually coming in the front door, this will at least give you an idea of what you can't touch. Them you just have to go over what's left, hopefully pulling in other people who've been around the company for a long time to help.

share|improve this answer

You could in theory simply mine your access log to see what URLs people are requesting, rather than enabling RewriteLog (which may have a performance impact). If you wanted to get fancy, you could replace your static RewriteRules with a programmatic RewriteMap and then maintain actual statistics on how often the rewrites are used.

share|improve this answer

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.