Have you ever encountered an HTTP 406 (“Not Acceptable”) error? I hadn’t, until this afternoon. I didn’t even know such an error existed. Now I know at least one way to fix it.
An HTTP 406 error tells whoever is using your site that it can’t handle a particular request. It can find the file—otherwise it would issue a 404 error—but the file falls outside the limits of what it is prepared to accept.
After much searching, I found that this means it has problems with the MIME type—or the language of the file. Or maybe the file is malformed in some way.
My file was a PHP file, delivering standard text/html after PHP pre-processing, so there could be no problem with the MIME type. It was in a huge set of similar files which had no problems. I rewrote code, checked brackets, etc., etc.
Then I checked whether it was even being called. It was a secure file, with an immediate relocation to a simple site 403 file, if the caller had no right to be calling it. When I tried to access it without permission, I just got the 406 error again. Which meant the file hadn’t even been passed to the PHP pre-processor.
OK. Experiment of last resort. When saving the file in the first place, had I let in a weird character into the file name or its extension? (I have to use a Spanish keyboard.) To find out, I renamed the file, extension and all, making sure I pressed only the right keys.
I uploaded the newly named file, after changing the links in the rest of the setup. Suddenly, everything worked like a dream. If you ever encounter an HTTP 406 error, see if this fix works for you.