为什么用.htaccess重写URL指向索引?

时间:2013-12-26 16:45:54

标签: .htaccess mod-rewrite

我想将example.com/test重定向到example.com/good.php,保持我的优秀www重写,但它始终指向index.php,为什么?

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(([^\.]+))\.com [NC]
RewriteRule ^(.*)$ http://%1.com%{REQUEST_URI} [R=301,L]
RewriteRule ^http://www\.(([^\.]+))\.com/test$ good.php [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

1 个答案:

答案 0 :(得分:0)

RewriteRule不适用于完整的URL,它只适用于路径,所以你的rewriteRule for good.php可以像RewriteRule ^test$ good.php [R=301,L]一样简单