.htaccess RewriteRule在浏览器中没有更改URL

时间:2012-11-02 11:09:44

标签: .htaccess mod-rewrite

我有.htaccess个文件:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^somedomain.com [NC]
RewriteRule ^(.*)$ http://www.somedomain.com/$1 [R=301,NC]

RewriteRule ^r/(.*)$ index.php?rid=$1 [NC]

但是当我请求www.somedomain.com/r/123之类的网址时,最后一个条件会在浏览器中执行重定向,并显示www.somedomain.com/index.php?rid=123之类的网址。但我需要调用此脚本而不更改URL。

怎么了?

1 个答案:

答案 0 :(得分:3)

您使用R=301尝试使用L,如下所示:

RewriteCond %{HTTP_HOST} ^somedomain.com [L]
RewriteRule ^(.*)$ http://www.somedomain.com/$1 [L]

RewriteRule ^r/(.*)$ index.php?rid=$1 [L]