HTTP 406 Error

Aug 20, 2005 | Tags: , , , , | Written by John

Some work I've been doing recently has involved debugging a Mambo installation. The website had developed the curious ability to block the editing of certain articles, but allowed other ones through. These blocked attempts to save articles were resulting in a '406 Not Acceptable' error.

According to the W3 specification, this means:

The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

Say what?

After a lot of hair-pulling I tracked the problem down to a few words, such as '<script' and '&amp;', which when included caused the error. This made me very suspicious - why would Mambo only block this HTML code? I explored further by inserting debug code into Mambo and then waited for the result... nothing. Mambo wasn't even being called.

This meant the problem must be before Mambo, and there was only one thing that could be responsible: Apache.

Some Googling later and I found information about an optional Apache module called mod_security. This is a very nice module that acts as an Apache firewall - it blocks a lot of the usual routes that people use to hack websites. In particular it scans POST requests (sent when you 'save' something on a website'), and displays a 406 error for anything controversial. Bingo!

The reason I'm documenting these frustrating few hours of my life is in the hope that it may prove useful to someone else. It appears that mod_security, if configured aggressively, can cause a lot of problems and these may manifest themselves in Mambo, WordPress, or any piece of web software.

The solution was very simple. The following lines were added to the .htaccess file to disable mod_security:

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

Naturally you loose any benefits that mod_security might bring, but that's better than a non-functioning website, and you can always ask for the security configuration to be toned down to a more acceptable level.

Share This

Comments (page 2 of 6)

  1. author
    mike :

    Aug 31, 2006 7:35 am

    Thank you, solved my ocs_inventory install problem

  2. author
    BC :

    Aug 22, 2006 3:28 am

    Thank you so much for sharing this fix. It immediately solved an issue I had where Joomla Blog was not allowing me to post full lenght articles over a certain character max, atleast I thought it was Joomla. Thanks again.

  3. author
    Nikola :

    Aug 11, 2006 6:35 pm

    10x a lot !!!! Realy helped !!! :)

  4. Matt :

    Aug 11, 2006 3:17 am

    Thank you so much! Was getting ready to explode with slight stress! :)

  5. Fabio Gameleira :

    Jun 27, 2006 5:52 am

    Very good! I'm using Joomla! 1.0.9 and I want to let you know that this fixed my problem too.

    Thanks a lot ,
    from Rio de Janeiro - Brazil!

  6. Paul :

    Mar 4, 2006 7:59 pm

    Thanks a lot! It solved the problem. I'm a Web designer and no idea what was that error... a quick googling resolved hours of frustration

    Regards

  7. WEB :

    Feb 22, 2006 3:25 pm

    Well Done! Thanksssssssssssssssssssssssssssssssssssssssss man!

  8. author
    seb :

    Feb 10, 2006 3:04 am

    Here also a huge thanx. I had the mysterious problem within the phpwcms system.

  9. Dave :

    Feb 7, 2006 2:52 am

    YES!!!! Thankyou, thankyou, thankyou! Was beating my head on a wall before I found this post, so thanks for helping me out!!

  10. Kumar :

    Dec 31, 2005 6:32 am

    Larry Page and Sergie Brin deserve more thanks than you. It is Google who send me to your page.
    Thanks for saving my hairs. ;-)

Leave a comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Home | Software | Terms & Conditions | Sitemap | John Godley © 2008
Close
E-mail It