Htaccess - RewriteCond: only php as file extension
I want to apply a rewrite condition, so that only *.php fil开发者_如何学Ces are affected:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} /.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /example.php [L]
The first condition here does not seem to work for files inside a directory like www.test.com/test/example.php (only for www.test.com/example.php).
Thanks for help.
Try this code instead:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^\.]+\.php$ /example.php [L,NC]
精彩评论