gpt4 book ai didi

.htaccess - 如果参数等于某值,则 mod_rewrite 拒绝访问

转载 作者:行者123 更新时间:2023-12-04 06:20:43 25 4
gpt4 key购买 nike

我有这样的网址
mydomain.com?act=somethingbad
mydomain.com?act=更糟的东西

mydomain.com?act=somethinggood
mydomain.com?act=更好的东西

我需要禁止不良行为。
尝试过类似的东西:

RewriteCond %{QUERY_STRING} act=(.*)
RewriteCond %{QUERY_STRING} act=[^(somethinggood)]
RewriteRule ^(.*) - [F]

因为我的坏行为多于好行为,所以我想从这条规则中排除好行为。
但是上面的例子不起作用。

最佳答案

使用这些规则:

RewriteCond %{QUERY_STRING} (^|&)act=(.*)
RewriteCond %{QUERY_STRING} !(^|&)act=(somethinggood|somethingbetter)(&|$)
RewriteRule ^(.*) - [F]
  • 参数 act可以是任何地方(例如 http://example.com/?act=somethinggoodhttp://example.com/?mode=happy&act=somethinggoodhttp://example.com/?mode=happy&act=somethinggood&extra=yes 都可以)
  • 如果 act 的值为空参数,它将被拒绝(例如 http://example.com/?act= 被视为 BAD 参数)
  • 根据您提供的 URL 示例,此规则将应用于具有 act 的所有 URL。查询字符串中的参数。
  • 关于.htaccess - 如果参数等于某值,则 mod_rewrite 拒绝访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6610468/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com