Apache Module mod_rewrite

Some things to remember when working with Apache module mod_rewrite and dynamic websites: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
  • <CondPattern‘ (lexicographically precedes) Treats the CondPattern as a plain string and compares it lexicographically to TestString. True if TestString lexicographically precedes CondPattern.
  • >CondPattern‘ (lexicographically follows) Treats the CondPattern as a plain string and compares it lexicographically to TestString. True if TestString lexicographically follows CondPattern.
  • =CondPattern‘ (lexicographically equal) Treats the CondPattern as a plain string and compares it lexicographically to TestString. True if TestString is lexicographically equal to CondPattern (the two strings are exactly equal, character for character). If CondPattern is "" (two quotation marks) this compares TestString to the empty string.
  • -d‘ (is directory) Treats the TestString as a pathname and tests whether or not it exists, and is a directory.
  • -f‘ (is regular file) Treats the TestString as a pathname and tests whether or not it exists, and is a regular file.
  • -s‘ (is regular file, with size) Treats the TestString as a pathname and tests whether or not it exists, and is a regular file with size greater than zero.
  • -l‘ (is symbolic link) Treats the TestString as a pathname and tests whether or not it exists, and is a symbolic link.
  • -F‘ (is existing file, via subrequest) Checks whether or not TestString is a valid file, accessible via all the server’s currently-configured access controls for that path. This uses an internal subrequest to do the check, so use it with care – it can impact your server’s performance!
  • -U‘ (is existing URL, via subrequest) Checks whether or not TestString is a valid URL, accessible via all the server’s currently-configured access controls for that path. This uses an internal subrequest to do the check, so use it with care – it can impact your server’s performance!