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 page-new.php>
SecFilterInheritance Off
<Files post.php>
SecFilterInheritance Off
<Files page.php>
SecFilterInheritance Off
<Files theme-editor.php>
SecFilterInheritance Off
<Files options-general.php>
SecFilterInheritance Off

You may also like...

14 Responses

  1. Sarah says:

    I’ve altered the original code as it was incorrect!

  2. ses5909 says:

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

  3. Sarah says:

    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.

  4. Sapphire says:

    Oh, very cool! It is much easier to have all your htaccess stuff in one file, so I’m moving mine over too.

  5. Sarah says:

    Hey Sapphire, thanks for the original post 🙂 Glad I’ve helped improved things!

  6. Drew Jones says:

    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!

  7. Sarah says:

    Cheers for the comment Drew 🙂

  8. Sam says:

    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.

  9. Sarah says:

    No problem Sam, glad to hear it’s all working now 🙂

  10. With Mod security 2, this is no longer valid. I’ve written about it and a workaround at

  11. anouar says:

    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

  12. Sarah says:

    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

  13. anouar says:

    thanks sara;now all sorted
    you are my hero lol

    have a nice day

  1. Sat, 13 November, 2010

    […] a fascinating article on the topic of directory security. <Files post-new.php> SecFilterInheritance Off </Files> <Files page-new.php> […]