我以不同的方式尝试过它,但对我来说也不起作用。
在重写规则中匹配问号
请帮我这个
重定向到其他网址
http://localhost/crb/index.html?q=xxxxxxxx
要
http://localhost/crb/demo/result?q=xxxxxxxx
我试过这个
Options +FollowSymlinks
RewriteEngine on
rewriterule ^crb/index.html?q=xxxxxxxx(.*)$ http://localhost/crb/demo/result?q=xxxxxxxx$1 [r=301,nc]
答案 0 :(得分:3)
根据查询字符串使用重写:
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^q=xxxxxxxx(.*)$
RewriteRule ^/?crb/index.html http://localhost/crb/demo/result?q=xxxxxxxx%1 [R=301,NC]
答案 1 :(得分:0)
您可以尝试查询字符串追加(QSA)标记:
for i in mylist:
if i == 1:
result = 1
elif i > 1 and i < 2:
result = 2
elif i == 3:
result = 3
a.append(result)
这应该将现有的查询字符串(q = xxxxxxxx)附加到新网址。
https://wiki.apache.org/httpd/RewriteFlags/QSA
http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_qsa
如果此代码无效,请稍微修改一下,然后重试。