Disable Mod-Security only for the perticular file or directory

You can disable mod-security by using two ways:

1) You can add following rules in .htaccess file
~~~~~~~~~~~~~~
#For mod secuity 2
<IfModule mod_security2.c>
<LocationMatch “/index.php“>
SecRuleRemoveById 12345
</LocationMatch>
</IfModule>
~~~~~~~~~~~~~~
#For mod secuity 1
<IfModule mod_security.c>
<Location /index.php>
SecFilterRemove12345
</Location>
</IfModule>
~~~~~~~~~~~~~~

or

2) You can disable it by using http.conf file.

open the httpd.conf file and search the domain.com and remove the conment from below line

# Include “/usr/local/apache/conf/userdata/username/domain.com/*.conf”
to
Include “/usr/local/apache/conf/userdata/username/domain.com/*.conf”

then create the directory '/usr/local/apache/conf/userdata/username/domain.com/' using the following command:

mkdir -p /usr/local/apache/conf/userdata/username/domain.com/

vi /usr/local/apache/conf/userdata/username/domain.com/allow.conf
and edit the mod-security rule as follows:

~~~~~~~~~~~
#For mod secuity 2
<IfModule mod_security2.c>
<LocationMatch “/index.php“>
SecRuleRemoveById 12345
</LocationMatch>
</IfModule>
~~~~~~~~~~~
#For mod secuity 1
<IfModule mod_security.c>
<Location /index.php>
SecFilterRemove 12345
</Location>
</IfModule>
~~~~~~~~~~~

If the server does not shows the ID instead shows directory or file name

then

1) You can add following rules in .htaccess file

<IfModule mod_security.c>
<Files XYZ/abc.gif>
SecFilterInheritance Off
</Files>
</IfModule>

Done. :)

Note : Replace the domain.com equal to orginal domain name, “/index.php equal to exact file path which is mention the error and ” 12345″ equal to the original id which is in the error and "XYZ/abc.gif" equal to the exact directory/file/

Thank you.

Comments

Post a Comment

Popular posts from this blog

SVN: File remains in conflict

12 tweakings for WHM/cPanel to speed up WordPress

HowTo: Enable extended logging for exim