【问题标题】:Apache Mod-Rewrite rule condition required to Dynamic Query String positions动态查询字符串位置所需的 Apache Mod-Rewrite 规则条件
【发布时间】:2012-02-20 23:23:30
【问题描述】:

我有一个类似http://localhost/test.html?param1=a&param2=b&param3=c 的网址 我希望重写条件来检查查询参数 param1、param2 和 param3 可以是任何顺序..它可能如下所示

http://localhost/test.html?param3=a&param2=b&param1=c
http://localhost/test.html?param2=a&param3=b&param1=c
http://localhost/test.html?param3=a&param1=b&param2=c

请帮助我如何重写此查询字符串的条件。我可以用 [OR] 条件编写所有组合,但有没有最好的方法来实现这一点?

谢谢

【问题讨论】:

    标签: apache mod-rewrite


    【解决方案1】:

    这样写:

    RewriteCond %{QUERY_STRING} (^|&)param1=[^&]*(&|$) [NC,OR]
    RewriteCond %{QUERY_STRING} (^|&)param2=[^&]*(&|$) [NC,OR]
    RewriteCond %{QUERY_STRING} (^|&)param3=[^&]*(&|$) [NC]
    RewriteRule ^test\.html$ target-uri-goes-here? [NC,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-23
      • 2019-09-13
      • 2011-07-20
      • 1970-01-01
      相关资源
      最近更新 更多