14

Although being a decent web developer, I and most of my colleagues always struggle with basic tasks when using mod_rewrite.

I read the manuals and understood most of it, however most skills I've learned in life are by doing. The trouble is, there's no easy way to debug the configuration. Most of the time if I succeed at configuring the .htaccess file it's by sheer random luck not by trial and error.

I realize one can read Apache error logs or pass rewriteRule results to GET parameters and present them in say, PHP files, but that's inconvenient and slow.

So, the question. Is there a tool for writing and debugging .htaccess directives? Update: given that questions asking for libraries and similar are frequently closed as out of scope for SO, is there a more general technique for doing this?

Foon
  • 6,148
  • 11
  • 40
  • 42
raveren
  • 17,799
  • 12
  • 70
  • 83
  • What sort of information beyond what you can get with `RewriteLog` are you looking for for debugging purposes? (This is an actual question by the way, not a "Why isn't that good enough for you?!" quip or anything like that) – Tim Stone Aug 05 '10 at 16:45
  • Well something more real-time. I'd imagine an interface where you enter one or more addresses and see what they map to when changing settings. – raveren Aug 05 '10 at 16:59
  • 2
    This is hampered a little by the fact that some of the resolution done by `mod_rewrite` involves crossing the line between URLs and local filepaths (`%{REQUEST_FILENAME}`, for example). Unfortunately the intricacies of this are one of the areas that cause the most problem for people, and might be hard to have a program simulate correctly. I'm sure it's do-able to at least some extent (if not all) though, and could be useful; I'm afraid I'm not aware of any existing program myself, but it does sound like an interesting project. – Tim Stone Aug 05 '10 at 17:20
  • Tim, this should have been an answer. – raveren Aug 06 '10 at 09:05

2 Answers2

26

You could use our htaccess tester. It allows you to test basic rewrite rules and conditions, we are trying to improve it's functionality over time but it does the job quite well with the current feature set.

andreascreten
  • 361
  • 3
  • 4
0

unit testing tools won't be of much help here. look for functional testing tools.

bcosca
  • 17,371
  • 5
  • 40
  • 51