Gau*_*wal 34 php apache .htaccess
如何在Apache服务器上mod_security
使用.htaccess
文件禁用?
我在我的个人域名上使用WordPress并发布一个内容有一些代码块的帖子,根据我的托管服务提供商说mod_security
出现错误,我的IP已进入防火墙因为mod_security
.
所以我想mod_security
通过使用.htaccess
文件禁用.
Xyo*_*yon 45
可以这样做,但很可能是mod_security
因为某个原因而实现了您的主机.请确保他们批准您为自己的网站禁用它.
那就是说,应该这样做;
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
Run Code Online (Sandbox Code Playgroud)
当上述解决方案不起作用时,请尝试以下操作:
\n\n<IfModule mod_security.c>\n SecRuleEngine Off\n SecFilterInheritance Off\n SecFilterEngine Off\n SecFilterScanPOST Off\n SecRuleRemoveById 300015 3000016 3000017\n</IfModule>\n
Run Code Online (Sandbox Code Playgroud)\n
在某些服务器和Web主机上,可以通过.htaccess
但仅完全禁用ModSecurity - 您无法禁用单个规则.
不是为整个网站禁用它,而是最好将其限制为特定的URL.您可以在<If>
下面的语句中通过正则表达式指定要匹配的URL ...
### DISABLE mod_security firewall
### Some rules are currently too strict and are blocking legitimate users
### We only disable it for URLs that contain the regex below
### The regex below should be placed between "m#" and "#"
### (this syntax is required when the string contains forward slashes)
<IfModule mod_security.c>
<If "%{REQUEST_URI} =~ m#/admin/#">
SecFilterEngine Off
SecFilterScanPOST Off
</If>
</IfModule>
Run Code Online (Sandbox Code Playgroud)
只是为了更新有关mod_security 2.7.0+的问题,他们关闭了通过htaccess缓解modsec的功能,除非您使用该--enable-htaccess-config
标志进行编译。大多数主机不使用此编译器选项,因为它允许过于宽松的安全性。相反,httpd.conf中的虚拟主机是控制modsec的首选方法。
即使您确实使用htaccess缓解措施来编译modsec,也可以使用较少的指令。SecRuleEngine
例如不能再在那里使用。如果允许,以下是默认情况下可以在htaccess中使用的列表(请注意,主机可能会进一步限制此列表的使用AllowOverride
):
- SecAction
- SecRule
- SecRuleRemoveByMsg
- SecRuleRemoveByTag
- SecRuleRemoveById
- SecRuleUpdateActionById
- SecRuleUpdateTargetById
- SecRuleUpdateTargetByTag
- SecRuleUpdateTargetByMsg
Run Code Online (Sandbox Code Playgroud)
作为对2.x用户的补充说明:IfModule
现在应该寻找,mod_security2.c
而不是较旧的mod_security.c
对于包括NameCheap在内的某些网络主机,无法使用 禁用 ModSecurity .htaccess
。唯一的选择是联系技术支持并要求他们为您更改配置。