首页 文章

.htaccess和Apache ModSecurity

提问于
浏览
1

我有这个.htaccess

Options -Indexes

    RewriteEngine On
    RewriteBase /

    # Force to exclude the trailing slash
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.*)/$
    RewriteRule ^(.+)/$ $1 [R=307,L]

    # Restrict php files direct access
    # this part generate the problem
    RewriteCond %{THE_REQUEST} ^.+?\ [^?]+\.php[?\ ]
    RewriteRule \.php$ - [F] 

    # Allow any files or directories that exist to be displayed directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php?$1 [QSA,L]

但阿帕奇给我写了这个:

ModSecurity:警告 . 需要匹配“在%内”与“REQUEST_METHOD” . [file“/modsecurity/modsecurity_crs_30_http_policy.conf”] [line“31”] [id“960032”] [rev“2”] [msg“策略不允许使用方法”] [data“GET”] [severity“CRITICAL “] [ver”OWASP_CRS / 2.2.9“] [maturity”9“] [准确度”9“] [tag”OWASP_CRS / POLICY / METHOD_NOT_ALLOWED“] [tag”WASCTC / WASC-15“] [tag”OWASP_TOP_10 / A6 “] [tag”OWASP_AppSensor / RE1“] [tag”PCI / 12.1“]

我该如何编辑我的htaccess?多谢你们 .

1 回答

  • 0

    正如第一条评论所说,您有一条阻止您的请求的ModSecurity规则 . 如果您的托管服务提供商在构建ModSecurity时启用了“--enable-htaccess-config”,那么您可以从htaccess文件中禁用该特定规则 . 您可以使用类似于以下内容的内容:

    <IfModule mod_security.c> SecRuleRemoveById 960032 </IfModule>

    但是,如果您的提供程序未启用此功能,并且您无权访问任何Apache配置文件(httpd.conf等) . 然后,您必须联系您的托管服务提供商以解决问题 . 抱歉

相关问题