Getting a 406 Error with WordPress?

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?”

  1. I've altered the original code as it was incorrect!

    By Sarah on Thu, 25 October, 2007

  2. I haven't seen this before but have filed away for future use. I may need it someday!

    By ses5909 on Fri, 26 October, 2007

  3. 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 Fri, 26 October, 2007

  4. 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 Sun, 28 October, 2007

  5. Hey Sapphire, thanks for the original post :) Glad I've helped improved things!

    By Sarah on Sun, 28 October, 2007

  6. 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 Tue, 18 March, 2008

  7. Cheers for the comment Drew :)

    By Sarah on Wed, 19 March, 2008

  8. 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 Sat, 26 April, 2008

  9. No problem Sam, glad to hear it's all working now :)

    By Sarah on Sat, 26 April, 2008

  10. 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 Thu, 1 May, 2008

  11. 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 Tue, 24 June, 2008

  12. 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 Tue, 24 June, 2008

  13. thanks sara;now all sorted
    you are my hero lol

    have a nice day

    By anouar on Wed, 25 June, 2008

Leave a Comment

Please use your real name or nickname. Spam names will be changed.