Thursday, January 23, 2014

htaccess Rewrite Rules

This tool lets you write and test your rewrite rules for Apache's mod_rewrite on-the-fly. This site requires Javascript to be enabled. Rules are saved in a session, so they are deleted after ~30 minutes of inactivity. Don't get distracted.
What Works?
  • RewriteRule statements with backreferences. The patterns are implemented as full POSIX-compliant regular expressions; I still need to work out any inconsistencies with mod_rewrite's parser.
  • The RewriteRule flags that make sense/have an effect on the parsing in this tool. Currently C (chain), S (skip), L (last), NC (nocase), QSA (qsappend) and N (next) are supported.
  • RewriteCond variables, i.e. %{REMOTE_HOST}, and the two flags that RewriteCond supports: NC (nocase) and OR (ornext). Note that the tool does not check that you're using valid variable names.
  • RewriteCond backreferences, both RewriteCond and RewriteRule. %1 refers to the first subpattern of the last RewriteCond in this group, $0 refers to the first subpattern of the RewriteRule that the current RewriteCond applies to. Yes, one is 0-indexed and the other is not.

What Doesn't Work?
  • RewriteMaps aren't supported because of the amount of work needed to implement it here and the ease with which one can test them already.
  • RewriteBase isn't supported because it doesn't really make sense here.
  • The other mod_rewrite options aren't interesting in this context either.


Open This Tool

Contact Form

Name

Email *

Message *