Ad Code

How to Disable mod_security using .htaccess

Advertisements
ModSecurity is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx that is developed by Trustwave's SpiderLabs. It has a robust event-based programming language which provides protection from a range of attacks against web applications and allows for HTTP traffic monitoring, logging and real-time analys…

How to Disable mod_security using .htaccess


Here are the steps to disable mod_security using .htaccess. Before proceeding further please ensure you have enabled mod_rewrite in your Apache server. Here are the steps to enable .htaccess in Apache

Disable mod_security in .htaccess

Add the following code to your .htaccess file to turn off mod_security in Apache web server.

Code: 1

<IfModule mod_security.c>

SecFilterEngine Off

SecFilterScanPOST Off

</IfModule>


OR

On some servers and web hosts, it's possible to disable ModSecurity via .htaccess, but be aware that you can only switch it on or off, you can't disable individual rules.

But a good practice that still keeps your site secure is to disable it only on specific URLs, rather than your entire site. You can specify which URLs to match via the regex in the <If> statement below...

### 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>


OR

Just to update this question for mod_security 2.7.0+ - they turned off the ability to mitigate modsec via htaccess unless you compile it with the --enable-htaccess-config flag. Most hosts do not use this compiler option since it allows too lax security. Instead, vhosts in httpd.conf are your go-to option for controlling modsec.

Even if you do compile modsec with htaccess mitigation, there are less directives available. SecRuleEngine can no longer be used there for example. Here is a list that is available to use by default in htaccess if allowed (keep in mind a host may further limit this list with AllowOverride):

- SecAction - SecRule - SecRuleRemoveByMsg - SecRuleRemoveByTag - SecRuleRemoveById - SecRuleUpdateActionById - SecRuleUpdateTargetById - SecRuleUpdateTargetByTag - SecRuleUpdateTargetByMsg


OR

In .htaccess file at site root directory edit following line:

<ifmodule mod_security.c>

SecFilterEngine Off
SecFilterScanPOST Off

</ifmodule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Just keep the mod_security rules like SecFilterEngine and parts apart from each other. Its works for apache server

OR


When the above solution doesn’t work try this:

Code: 

<IfModule mod_security.c>
  SecRuleEngine Off
  SecFilterInheritance Off
  SecFilterEngine Off
  SecFilterScanPOST Off
  SecRuleRemoveById 300015 3000016 3000017
</IfModule>

Finaly Save It.

Source: https://stackoverflow.com/questions/12928360/how-can-i-disable-mod-security-in-htaccess-file
Download Link
Advertisements

Post a Comment

0 Comments