Theme editor

Guide How to Fix the "406 Not Acceptable" Error (A Quick mod_security Fix)

SecureOptimize

🐺⚔️ 𝐎𝐥𝐝 𝐖𝐨𝐥𝐟 ⚔️🐺
Corporate User
Thread owner

What is the "406 Not Acceptable" Error?​

Ever seen a "406 Not Acceptable" error and panicked? 😱 It’s a frustrating roadblock, but the fix is often surprisingly simple.

This error usually doesn't mean your website is broken. Instead, it’s typically your server's firewall, known as mod_security (or a WAF - Web Application Firewall), being a bit too protective. It has flagged a request that it considers unsafe or "suspicious" and decided to block it just in case.

If your website runs on an Apache server, you can usually fix this by adding a simple directive to your .htaccess file.

🛠️ The Quick Solution: Editing Your​

Let's get straight to the fix. You just need to add the following lines to your website's .htaccess file. This file is usually located in the root folder of your site (where your index.php or index.html file is).

Paste this code at the top or bottom of your .htaccess file:
Bash:
<IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

What does this code do? It tells mod_security to stop filtering requests for your site. SecFilterEngine Off disables the filter, and SecFilterScanPOST Off specifically stops it from scanning data sent through forms, which is a common trigger for 406 errors during file uploads or form submissions.

⚠️ Important: A Word of Warning​

Think of this solution as turning off your home's smoke alarm because you burned some toast. It stops the noise, but it's not a safe long-term strategy on a live website. Disabling mod_security completely can leave your site vulnerable to attacks.

This code is fantastic for:
  1. Quick Troubleshooting: It instantly tells you if mod_security was the real cause of the 406 error.
  2. Development Sites: It's generally fine to use on a staging or development site that isn't public.
 
Last edited by a moderator:
Thread owner
For a permanent solution on a live server, the best practice is to identify the specific rule that is being triggered and "whitelist" (disable) only that single rule. This keeps your firewall active while allowing your legitimate request to pass. You may need to contact your hosting provider to help with this.

But for a fast fix to get your site working again, the .htaccess code above is the quickest way to solve the "406 Not Acceptable" error.
 
Back
Top