0

A project that I am newly working on has been around for years, and it has managed to accumulate several hundred rather complex RewriteRules within the Apache conf files.

When working with some files, I have been able to figure out which rules affect them. However, in other cases I am completely stuck at figuring it out. My method so far has been to manually look through the various conf files, and grep them for certain keywords.

Is there a better way to do this?

Some of the things which I can think of are:

  • Is there a command or REPL where I can enter a path, and it return that name of the file that it serves?
  • Is there a tool that will let you do the above, and also highlight which lines in the conf files re-wrote that rule?
  • Is there a way to inspect the log files to determine what the input path and corresponding file served path were?

... but I am not sure where to begin with any of these.

1
  • 1
    Have you enabled RewriteLog? This is the easiest way to follow what rewrites are happening.
    – Paul
    Mar 12, 2014 at 0:44

2 Answers 2

2

Please enable the RewriteLog directive that Paul mentioned above. Then set the value of the RewriteLogLevel directive to 2.

After that start to increase the value of RewrireLogLevel up to 9 until you see the necessary details recorded to the log file.

0
0

agree with above, to enable rewrite log, simply add

RewriteLog <file-path>
RewriteLogLevel 2

to your virtualhost file, then restart apache

the man file for mod rewrite can be found here

1
  • I would have commented this, but miss some karma to do that.. sorry
    – Sverre
    Mar 12, 2014 at 14:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .