Here is my question
My simple regex is working just fine, i just want to make sure that the first part of the regex short circuits for efficiency, i put my questions inline
1- What this thing is supposed to do is, the files with the listed extensions should not be re-written if the file exists, if the file does not exist, we rewrite the request to our php file, all other file types are always rewritten, regardless of a file's existence.
- First condition, does the file have any of the following extensions?
For example:
RewriteCond %{REQUEST_FILENAME} \.(php|gif|jpg|png|ico|swf|flv|avi|mpg|jpeg|gz|ram)$
Second condition, if the file is one of our extensions above, does it exist on the file system?
The evaluation of this statement is costly and I want to make sure that we short circuited on the previous RewriteCond and that this will only be checked for value if the above evaluates to true.
- also need to know if the operating system or apache will cache the result of the file's existence (for example php does cache is_file() results)
For example:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ my_index.php?q=$1 [L,QSA]
- Directories and files to be left alone.... since if they passed
- the file existence test, they should not be rewritten at all
For example:
RewriteRule \.(php|gif|jpg|png|ico|swf|flv|avi|mpg|jpeg|gz|ram)$ - [L]
RewriteRule ^robots.txt$ - [L]
RewriteRule ^(.*)$ my_index.php?q=$1 [L,QSA]