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. Disablingmod_security completely can leave your site vulnerable to attacks.This code is fantastic for:
- Quick Troubleshooting: It instantly tells you if
mod_securitywas the real cause of the 406 error. - Development Sites: It's generally fine to use on a staging or development site that isn't public.
Last edited by a moderator: