{"id":437,"date":"2007-06-12T14:05:21","date_gmt":"2007-06-12T13:05:21","guid":{"rendered":"http:\/\/pete.nu\/blog\/2007\/06\/precondition-failed-when-trying-to-leave-a-comment-on-wordpress\/"},"modified":"2008-04-23T14:20:11","modified_gmt":"2008-04-23T13:20:11","slug":"precondition-failed-when-trying-to-leave-a-comment-on-wordpress","status":"publish","type":"post","link":"https:\/\/pete.nu\/blog\/2007\/06\/12\/precondition-failed-when-trying-to-leave-a-comment-on-wordpress\/","title":{"rendered":"Precondition Failed when trying to leave a comment on WordPress"},"content":{"rendered":"<p>A reader emailed me a little while back to tell me that he&#8217;d been having difficulty leaving a comment on my site &#8211; he&#8217;d get the error &#8220;412 Precondition Failed&#8221;.<\/p>\n<p>I did some investigation and found that sentences such as *&#8221;However, its a far cry to be able to create a food sample from scratch.&#8221;* and *&#8221;As a computer programmer yourself, you&#8217;d probably find it easy to program a computer to create hit songs from scratch, right?&#8221;* were causing the problem, and if I reworded them, the comment would be allowed through.<\/p>\n<p>I did a bit of digging around and came to the conclusion that these sentences were being rejected because they looked like an attempt to hack the site. I consulted my web hosts, <a href=\"http:\/\/34sp.com\/\">34sp<\/a>, and they confirmed that mod_security was rejecting them because they took the format &#8220;create blah blah blah from&#8221;, which could be construed as an attempt at a SQL command.<\/p>\n<p>Leaving aside how unintuitive the error was (surely 403 Forbidden would be much more appropriate than 412 Precondition Failed?), there is a solution. You can disable this particular rule by putting the following line into your .htaccess file:<\/p>\n<p>    SecFilterRemove 300013<\/p>\n<p>The side-effect of this is that you will also lose additional protection against SQL injection attacks, so use it at your own discretion.<\/p>\n<p>*UPDATE: I realise now how much of a misnomer this post&#8217;s title is, as this problem has nothing to do with WordPress.*<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A reader emailed me a little while back to tell me that he&#8217;d been having difficulty leaving a comment on my site &#8211; he&#8217;d get the error &#8220;412 Precondition Failed&#8221;. I did some investigation and found that sentences such as *&#8221;However, its a far cry to be able to create a food sample from scratch.&#8221;* [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,12,2],"tags":[341,343,342],"class_list":["post-437","post","type-post","status-publish","format-standard","hentry","category-blogging","category-computing","category-titgig","tag-341","tag-mod_security","tag-precondition-failed"],"_links":{"self":[{"href":"https:\/\/pete.nu\/blog\/wp-json\/wp\/v2\/posts\/437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pete.nu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pete.nu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pete.nu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pete.nu\/blog\/wp-json\/wp\/v2\/comments?post=437"}],"version-history":[{"count":0,"href":"https:\/\/pete.nu\/blog\/wp-json\/wp\/v2\/posts\/437\/revisions"}],"wp:attachment":[{"href":"https:\/\/pete.nu\/blog\/wp-json\/wp\/v2\/media?parent=437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pete.nu\/blog\/wp-json\/wp\/v2\/categories?post=437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pete.nu\/blog\/wp-json\/wp\/v2\/tags?post=437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}