.htaccess重定向有效,但不能重写

时间:2011-06-17 16:11:49

标签: php .htaccess rewrite

这是我的.htaccess文件,它有效,因为第一个重写文件正确地重定向.html - > .php,但我希望也删除.php扩展名。如果有人能帮助我纠正我的代码,我会很感激。

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.html$ http://vbwtest.comeze.com/$1.php [R,NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php

2 个答案:

答案 0 :(得分:0)

试试这个。这会重写你的所有要求。

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [nc]

答案 1 :(得分:0)

从重写规则中删除R标志:

 RewriteRule ^(.+)\.html$ http://vbwtest.comeze.com/$1.php [NC]

[R,NC]中的R告诉它重定向而不是仅重写。

相关问题