Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 基于查询字符串参数重定向的重写规则是什么?_Apache - Fatal编程技术网

Apache 基于查询字符串参数重定向的重写规则是什么?

Apache 基于查询字符串参数重定向的重写规则是什么?,apache,Apache,如果请求的页面page1.html和查询字符串uin不是12或13,则让他们查看此page1.html页面,否则将其重定向到page2.html 更新:顺便说一句,查询字符串中还有其他参数。它们也应该发送到任意一页。您要查找的重写条件是%{QUERY\u STRING} 这里还有一个类似的问题:如果uin=12或uin=13,这将重定向到page2.html。整个查询字符串将发送到page2.html页面: # EDIT: Doesn't properly handle all cases

如果请求的页面page1.html和查询字符串uin不是12或13,则让他们查看此page1.html页面,否则将其重定向到page2.html


更新:顺便说一句,查询字符串中还有其他参数。它们也应该发送到任意一页。

您要查找的重写条件是%{QUERY\u STRING}


这里还有一个类似的问题:

如果uin=12或uin=13,这将重定向到page2.html。整个查询字符串将发送到page2.html页面:

 # EDIT: Doesn't properly handle all cases
 RewriteCond %{QUERY_STRING}  [\&]+uin=1[23][&]+ [OR]
 RewriteCond %{QUERY_STRING}  ^uin=1[23][&]+
 RewriteRule ^/page1\.html   /page2.html  [R]
编辑:这更好,可以处理查询字符串中任何位置的参数,无论是开始还是结束,还可以过滤掉字符串位于另一个参数中的情况,如suin=123

 RewriteCond %{QUERY_STRING} ^(.*&)*uin=1[23](&.*)*$
 RewriteRule ^/page1\.html   /page2.html  [R]
我在以下情况下进行了测试:

重定向:

没有重定向: