Getting a 406 Error with WordPress?
Thu, 25 October, 2007 – 6:09 pm
Some of you may have come across this before. You go to change something in a past post, or try to update a theme file and suddenly a 406 error appears instead of the 'Updated' comment such as
406 Not Acceptable
An appropriate representation of the requested resource /wp-admin/filename.php could not be found on this server.
I've had this in the past and didn't think much of it. Put it down to a blip within WordPress. However whilst working on a plugin for a client today I had the same error and figured I'd do a bit of searching before rewriting my plugin! A quick look on Yahoo and I came across ChillyCool who had posted up about this plus given a fix. Fantastic. However the fix was to add some code into a .htaccess file and save that into the wp-admin directory. This could cause problems as when I upgrade WordPress I simply delete the wp-admin directory and upload the new one from the new version. It's hard enough remembering not to delete my renamed wp-comments-post.php file let alone this .htaccess file too!
However you don't seem to need to put this into the wp-admin directory, it can go into the root of your site. So if you've suffered the same then add the following to your .htaccess and kiss those 406s goodbye! I've only added those that I know have caused me problems in the past. So if you find it happens on another file, just copy the last 3 lines and alter the path to suit the new filename.
<Files post-new.php>
SecFilterInheritance Off
</Files>
<Files page-new.php>
SecFilterInheritance Off
</Files>
<Files post.php>
SecFilterInheritance Off
</Files>
<Files page.php>
SecFilterInheritance Off
</Files>
<Files theme-editor.php>
SecFilterInheritance Off
</Files>
<Files options-general.php>
SecFilterInheritance Off
</Files>


13 Responses to “Getting a 406 Error with WordPress?”
I've altered the original code as it was incorrect!
By Sarah on Oct 25, 2007
I haven't seen this before but have filed away for future use. I may need it someday!
By ses5909 on Oct 26, 2007
It's very intermittent when it happens. Last night Dave tested his theme editor, half the files saved without a problem, but a few brought up this error. I've had it when trying to edit a couple of old posts to simply change their category.
Of course, it won't happen to everyone. Apparently 'mod_security' is disabled and the code above overrides that for the file specified.
By Sarah on Oct 26, 2007
Oh, very cool! It is much easier to have all your htaccess stuff in one file, so I'm moving mine over too.
By Sapphire on Oct 28, 2007
Hey Sapphire, thanks for the original post
Glad I've helped improved things!
By Sarah on Oct 28, 2007
Wordpress can be a pain if you dont know what you are doing. I have lived the nightmare of having to recreate my blog due to mistakes that I have made with wordpress.
Wordpress is way recommended by me. Your blog solution!
By Drew Jones on Mar 18, 2008
Cheers for the comment Drew
By Sarah on Mar 19, 2008
Thanks for this, Sarah
Was having problems with the media-upload.php file this afternoon after my upgrade to WP 2.5.1 yesterday. All sorted thanks to your code.
By Sam on Apr 26, 2008
No problem Sam, glad to hear it's all working now
By Sarah on Apr 26, 2008
With Mod security 2, this is no longer valid. I've written about it and a workaround at
http://tech.shantanugoel.com/2.....alore.html
By Shantanu Goel on May 1, 2008
hi sarah. im beginner in wordpress and i have problem when i try to upload image "An appropriate representation of the requested resource /wp-admin/media-upload.php could not be found on this server."
so how can i fix this error
thanks sarah
By anouar on Jun 24, 2008
Hi Anouar, You'd need to add the filename media-upload.php to the list as per the original post. ie. in your htaccess file add in
<Files media-upload.php>SecFilterInheritance Off
</Files>
By Sarah on Jun 24, 2008
thanks sara;now all sorted
you are my hero lol
have a nice day
By anouar on Jun 25, 2008