Heim  >  Artikel  >  Backend-Entwicklung  >  散分了,来人恢复一下。

散分了,来人恢复一下。

WBOY
WBOYOriginal
2016-06-13 12:50:33840Durchsuche

散分了,来人回复一下。。。

本帖最后由 laiyilong 于 2013-03-26 05:12:02 编辑 我们都知道PHP的REQUEST_URI是包括查询字符串的,就是等于浏览器地址栏的内容,但是从apache的文档上看到这个说明

REQUEST_URI
The path component of the requested URI, such as "/index.html". This notably excludes the query string which is available as as its own variable named QUERY_STRING.

意思应该是说查询字符串是独立在QUERY_STRING中的,而REQUEST_URI并不包含在其中,这让我觉得有点困惑,主要是不知道RewriteRule时^(.*)$包不包括查询字符串,例如我有个旧的网址old.com,别人访问 http://old.com/query.php?name=abc 时我要301重写到 http://new.com/query.php?name=abc 
<br />
RewriteCond %{HTTP_HOST} !^old\.com$ [NC]<br />
RewriteRule ^(.*)$ http://new.com/$1 [R=301,L]<br />


那这个 $1 是指 query.php 还是 query.php?name=abc 呢?如果不包含查询字符串,那我是不是要在 $1 后面在加个 %{QUERY_STRING} ???

------解决方案--------------------
楼主够早的,这么早高手都还没起床了。我也是刚刚起来才看到,先帮你顶一下。
------解决方案--------------------
引用:
没人回答,只好自己测试了,网上好像都找不到这些基础内容,英文的又看不懂,上面说错了,正确的是:

# REQUEST_URI 不包含 QUERY_STRING ;
# 锚点是本地浏览器处理的,不会发送到服务器 ;
# RewriteRule ^(.*)$ 匹配的是 {REQUEST_URI},不包括 {QUERY_STRING} ,QUERY_STRING会再重写……

早晨五点,这是在通宵么?生命是本钱~
mod_rewrite不会,有空研究一下。
------解决方案--------------------
该休息就早点休息啊。。。。。
------解决方案--------------------
通宵么?生命是本钱~

------解决方案--------------------
该回复于2013-03-27 09:10:42被管理员删除
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn