在重写规则的最后问号 [英] Question mark in the end of RewriteRule
本文介绍了在重写规则的最后问号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^oldpage\.php$ http://new-site.com/newpage-%1 [R=301,L]
and
RewriteRule ^oldpage\.php$ http://new-site.com/newpage-%1? [R=301,L]
在第一种情况下的结果是
new-site.com/newpage-3?id=3
在第二
new-site.com/newpage-3
In first case result is
new-site.com/newpage-3?id=3
in second
new-site.com/newpage-3
什么是排在第二重写规则问号意味着什么?
What does question mark in second rewrite rule means?
推荐答案
的?在目的地端(目的地是不是经常EX pressions)指去,没有查询字符串,它的目的地。
The ? at the end of a destination (destinations are not regular expressions) means to go to that destination with no query string.
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^oldpage\.php$ http://new-site.com/newpage-%1 [R=301,L]
如果查询字符串只包含一个ID,它存储,然后在目的地使用的值,所以如果你有
If the query string contains only an id, it stores the value which is then used in the destination, so if you have
http://foo.com/oldpage.php?id=54
你会最终与
http://new-site.com/newpage-54?id=54
如果您有
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^oldpage\.php$ http://new-site.com/newpage-%1? [R=301,L]
您会去同一目的地,一个空的查询字符串,所以打算
You'll go to the same destination but with an empty query string, so going to
http://foo.com/oldpage.php?id=54
将结束在
http://new-site.com/newpage-54
这篇关于在重写规则的最后问号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文