简体   繁体   中英

Error 406 - Not Acceptable - PHP Post with (%)

I'm having this problem with a form, whenever I submit a form in this new server I get a 406 Error - Not Acceptable.

I only have access to the FTP of this server so any changes I have to made is limited by that.

I've checked if mod_security is enabled by doing this:

<IfModule mod_security.c>

... Perform some kind of redirect or re-writing in here ...

</IfModule>

It didn't redirect so it means mod_security is not installed? If I run the redirect outside the IfModule tag it would redirect without any problem.

I've created a test form for you guys to test, just type in % on any field and click submit then it would display the error. Any alphabet character is okay and will not display the error.

(removed link)

Also I've added this in my htaccess file and the problem is still there.

<IfModule mod_security.c>
        SecFilterEngine Off
        SecFilterScanPOST Off
</IfModule>

What seems to be the problem here?

I had the same problem, and it was because of encoding. When the form fields had acute accents it failed, showing 406 error. I converted the files to UTF-8 and addded UTF-8 meta tag and now it's working without problem.

Edit: My original answer.

This is your problem .

You should look into sanitizing your data with the readily available PHP functions. They can be found here, at PHP.net.

This SO question may help you as well.

Sanitizing strings to make them URL and filename safe?

Best of luck.

I was wayyy off the mark here. My apologies.

In your position, I would simply contact my webhost - they may not be allowing your .htaccess to override that specific directive. Additionally, since you've only got FTP access, it seems like you'd be dependent on them anyway.

Again, best of luck. Since it isn't your webserver, you're at the mercy of your host.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM