开发者

Htaccess - RewriteCond: only php as file extension

开发者 https://www.devze.com 2023-03-11 07:19 出处:网络
I want to apply a rewrite condition, so that only *.php fil开发者_如何学Ces are affected: Options +FollowSymLinks

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消