没有在浏览器的URL变化的.htaccess重写规则重写、浏览器、规则、htaccess

2023-09-02 20:34:52 作者:遇覞︿浭ぬ菂臫巳

我有的.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]

不过,最后一个条件执行重定向浏览器时,我请求URL如 www.somedomain.com/r/123 并告诉我像 WWW网址。 somedomain.com/index.php?rid=123 。但我需要调用此脚本,而不URL改变。

But last condition performs redirect in browser when I request URL like www.somedomain.com/r/123 and show me URL like www.somedomain.com/index.php?rid=123. But I need call this script without URL change.

怎么了?

推荐答案

您使用了 R = 301 尝试使用就像下面这样:

You used the R=301 Try to use L just like following:

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

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