Summary. The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. The condition: RewriteCond %{REQUEST_URI} !(.

A simple explanation of how mod rewrite works by showing an example of a mod_rewrite script and the same logic written in pseudo-code. If you do not have a file or url that should not be rewritten, remove this line. This is just an example. Think about it - one (. By default, mod_rewrite maps a URL to a filesystem path. *)/$ finally fires when a url does not … However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch. Apache 2.x changes the definition of {REQUEST_URI} (to eliminate the leading /) so it will NOT match a leading / because is NOT part of its {REQUEST_URI} string. RewriteCond %{REQUEST_URI} ! example.php excludes a sample url that should not be rewritten. RewriteCond %{REQUEST_URI} !^/InvalidLink\.html$ [NC] The fact that the exception "works" if you first create this file, in which case the first condition ( !-f ) prevents the rewrite happening, suggests that the file is being processed OK and your cache is clear. h2. Syntax We should really encourage people to use the lexicographically equal operator instead of a [RegEx] if they want to ckeck, if _test string_ is lexicographically equal to _cond pattern_. The *RewriteCond* directive defines conditions under which the rewriting should take place.

The pseudo-code should help build some intuition on how the mod_rewrite script gets executed, and there is a followup link to a cheat sheet.