没有在浏览器的URL变化的.htaccess重写规则 [英] .htaccess RewriteRule without URL change in browser

查看:151
本文介绍了没有在浏览器的URL变化的.htaccess重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这篇关于没有在浏览器的URL变化的.htaccess重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆