2011-06-09 60 views
2

我想申请一个重写条件,因此,只有* .php文件会受到影响:.htaccess中 - 的RewriteCond:仅PHP作为文件扩展名

Options +FollowSymLinks 
RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} /.php$ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /example.php [L] 

这里的第一个条件似乎并不为内部文件的工作目录如www.test.com/test/example.php(仅限www.test.com/example.php)。

感谢您的帮助。

回答

2

试试这个代码,而不是:

Options +FollowSymLinks -MultiViews 
RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^[^\.]+\.php$ /example.php [L,NC] 
+1

对我的作品,谢谢了。 – Ilyssis 2011-06-09 12:33:03

相关问题