How to fix the mod_security error

October 21, 2024 / Security and Backup

This guide explains how to fix the mod_security error. A server-side problem called Mod_Security could cause the following error:
Error Message: “Not acceptable! An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.”

Here are a few approaches to resolve this error:

  1. Contact Your Hosting Provider:
    Since this is a server-side issue, the easiest and safest solution is to reach out to your hosting provider. Explain the issue to their support team, and they can either disable specific Mod_Security rules or whitelist the affected page to resolve the error.
  2. Disable Mod_Security through the .htaccess file:
    This method is not recommended as it disables the entire Mod_Security module, which could compromise your website’s security. If you still want to try it, follow these steps:

    1. Back up your .htaccess file from the ‘wp-admin’ directory.Create a new ‘.htaccess’ file using any text editor and add the following code:
      <IfModule mod_security.c> 
      
      SecFilterEngine Off 
      
      SecFilterScanPOST Off 
      
      </IfModule>
    2. Upload the new .htaccess file to the wp-admin directory on your server.If this doesn’t resolve the issue, you can also try the following:
    3. Back up your .htaccess file in the public_html directory.
    4. Open the .htaccess file with a text editor and add this code:
      <IfModule mod_rewrite.c> 
      
      RewriteEngine On 
      
      RewriteBase / 
      
      RewriteCond %{REQUEST_FILENAME} !-f
      
      RewriteCond %{REQUEST_FILENAME} !-d 
      
      RewriteRule . /index.php [L]
      
      </IfModule>
    5. Upload the modified file to the public_html directory.
  3. Disable Mod_Security for Specific URLs
    A more secure option is to disable Mod_Security only for certain URLs. To do this, use the following code, which targets specific paths (such as /admin/):

    <IfModule mod_security.c>
    
    <If "%{REQUEST_URI} =~ m#/admin/#">
    
    SecFilterEngine Off
    
    SecFilterScanPOST Off
    
    </If>
    
    </IfModule>

Disabling Mod_Security can resolve the error, but before implementing any changes, it is always a good idea to consult your hosting provider to ensure that you are not compromising your site’s security.

That is it!

Spread the love