如何逃离“?”在.htaccess mod_rewrite的使用正则表达式 [英] How to escape “?” using regex in .htaccess for mod_rewrite
本文介绍了如何逃离“?”在.htaccess mod_rewrite的使用正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是错的这个规则?
重写规则^页\?V =([^ /] +)$ page.php?V = $ 1 [L,NC]
我只想让URL看起来像
http://www.domainname.com/page?sk=info
解决方案
您不必包含查询部分,如果他们不反正改变。
重写规则^页$ page.php [L,NC]
在重写规则
将不符合任何部分的查询字符串。 页?V = 123
仍将成为 page.php?V = 123
另外,你的重写规则
使用?V =
,而你谈?SK =信息
What is wrong in this rule?
RewriteRule ^page\?v=([^/]+)$ page.php?v=$1 [L,NC]
I just want to make the URL looks like that
http://www.domainname.com/page?sk=info
解决方案
You don't have to include the query parts if they're not changing anyway.
RewriteRule ^page$ page.php [L,NC]
The RewriteRule
will not match any part of the query string. page?v=123
will still become page.php?v=123
Also, your RewriteRule
uses ?v=
while you talk about ?sk=info
这篇关于如何逃离“?”在.htaccess mod_rewrite的使用正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文