动态查询字符串位置所需的 Apache Mod-Rewrite 规则条件

发布于 2025-01-07 01:07:37 字数 435 浏览 1 评论 0原文

我有一个类似 http://localhost/test.html?param1=a&param2=b&param3=c 的 URL 我想要重写条件来检查查询参数 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] 编写所有组合条件,但有没有最好的方法来实现这一目标?

谢谢

I have an URL like http://localhost/test.html?param1=a¶m2=b¶m3=c
I want the rewrite condition to check query parameters param1,param2 and param3 can be in any order..it could be like below

http://localhost/test.html?param3=a¶m2=b¶m1=c
http://localhost/test.html?param2=a¶m3=b¶m1=c
http://localhost/test.html?param3=a¶m1=b¶m2=c

Please help me how can i rewrite conditions for this Query String .. I can write all the combination with [OR] condition but is there any best way to achive this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拿命拼未来 2025-01-14 01:07:37

像这样写:

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]

Write it like this:

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]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文