I am in need of the rewrite rules and conditions to evoke a central PHP script for every and any web document requested on my server. Just to add, I do not want the PHP script to be evoked when requests are made for CSS, JS, PNG, GIF, JPG, and other media etc. I only want the script to be called for HTM, HTML and PHP documents in the root and in any directory or subdirectory.
The main stumbling point I am having is I cannot get the script to be evoked for any of the assumed directory indexes. Here is what I am getting:
- http://sampleDomain.com/test/index.html (follows the RewriteRule and evokes myScript.php)
- sampleDomain.com/test/test.html (follows the RewriteRule and evokes myScript.php)
- sampleDomain.com/test/ (does not follow the RewriteRule - it displays a directory listing)
- sampleDomain.com/test (does not follow the RewriteRule - it displays a directory listing)
Here are my directives:
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-f [NC,OR]
- RewriteCond %{REQUEST_FILENAME} !-d [NC]
- RewriteRule . /phpDir/myScript.php [L]
What does the RewriteRule and RewriteCond look like to get every/any web document to evoke myScript.php?
Thanks.