By now you’ve likely figured out that the RewriteCond directive can and ought to be used to handle a variety of exceptions and special cases when testing conditions and processing rules.
Although the RewriteCond can be used and treated much like a regular expression, this doesn’t always have to be the case.
It’s likely the most common use when evaluating conditions and processing rules with the .htaccess file.
Below are a few of the cases in which rewrite conditions can be evaluated and process:
As a side note, you can also place an exclamation mark (!) in front of each case to test the negative expression rather than the implicit positive expression.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<ConditionPattern - Means is the string lower or less than pattern, replace ConditionPattern with the pattern you would like to test >ConditionPattern - Means is the string more or greater than pattern, replace ConditionPattern with the pattern you would like to test =ConditionPattern - Means is the string equal to than pattern, replace ConditionPattern with the pattern you would like to test -d - Evaluates if string is a valid directory -f - Evaluates if string is a valid file -s - Evaluates if string is a valid file and size is greater than zero -l - Evaluates if string is a symbolic link -F - Evaluates if string is a valid file, and accessible via subrequest -U - Evaluates if string is a valid file, and accessible via subrequest |
For example, !-f would mean if the string is NOT a valid file.
For more information on Rewrite Condition directives, conditions, exceptions, and flags, visit the Apace website.