Mod_rewrite: RewriteCond

For a plain English translation, go down to the end…

RewriteCond
Syntax: RewriteCond TestString CondPattern

The RewriteCond directive defines a rule condition. Precede a RewriteRule directive with one or more RewriteCond directives. The following rewriting rule is only used if its pattern matches the current state of the URI and if these additional conditions apply too.

TestString is a string which can contains the following expanded constructs in addition to plain text:
– RewriteRule backreferences
– RewriteCond backreferences
– RewriteMap expansions
– Server-Variables

Note that this is a simplified version of what’s at http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteCond
which goes on for several pages about this in vast detail.

To put it into plain English:
Say you have this (as can be found in a CodeIgniter .htaccess file):
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

What this means is:
IF the incoming Request URI (ie the address requested by the browser) matches “system”
THEN rewrite it so that it uses the index.php file in the root directory.

For explanation of RewriteRule see an earlier post.