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>

Trackback URL for this post: http://www.stuffbysarah.net/2007/10/25/getting-a-406-error-with-wordpress/trackback/
  • Sarah Comments:

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

  • ses5909 Comments:

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

  • Sarah Comments:

    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.

  • Sapphire Comments:

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

  • Sarah Comments:

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

  • Drew Jones Comments:

    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!

  • Sarah Comments:

    Cheers for the comment Drew :)

  • Sam Comments:

    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.

  • Sarah Comments:

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

  • Shantanu Goel Comments:

    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

  • anouar Comments:

    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

  • Sarah Comments:

    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>

  • anouar Comments:

    thanks sara;now all sorted
    you are my hero lol

    have a nice day

  • Pingback: htaccess Files | WebEnK

  • Leave a Reply

    Your email address will not be published. Required fields are marked *