【问题标题】:The Forbidden rule in htaccess using OR doesn't workhtaccess 中使用 OR 的禁止规则不起作用
【发布时间】:2019-12-16 03:48:26
【问题描述】:

对于不以 / 结尾且字符串名称为 view-ports 的 URL,此代码正确返回 403 错误

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{THE_REQUEST} !view-ports
RewriteRule ^ - [F]

我将在代码中添加更多字符串,例如view-ports,所以我尝试了以下代码:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{THE_REQUEST} !view-ports [OR]
RewriteCond %{THE_REQUEST} !string-2 [OR]
RewriteCond %{THE_REQUEST} !string-3
RewriteRule ^ - [F]

上面的代码不起作用,它对所有 URL 都返回 403 错误。

【问题讨论】:

    标签: apache .htaccess url


    【解决方案1】:

    我设法找到了答案,这里是:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !/$
    RewriteCond %{REQUEST_URI} !(view-ports|string-2|string-3)
    RewriteRule ^ - [F]
    

    【讨论】:

      猜你喜欢
      • 2010-10-16
      • 2017-09-03
      • 1970-01-01
      • 2013-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多