{"id":476,"date":"2011-12-23T22:52:45","date_gmt":"2011-12-23T22:52:45","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=476"},"modified":"2011-12-23T22:53:02","modified_gmt":"2011-12-23T22:53:02","slug":"apache-notdecoding-3f-404-errors","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/apache-notdecoding-3f-404-errors\/","title":{"rendered":"Apache not decoding %3F &#8211; causes 404 errors"},"content":{"rendered":"<p>This happens on only one of my servers, and I haven&#39;t been able to nail down the problem. It feels like a configuration related issue, yet I can&#39;t reveal any differences between the working and non-working configuration.<\/p>\n<p>An example URL:<\/p>\n<p>http:\/\/www.mysite.com\/test.html%3Fparam=1<\/p>\n<p>In a working configuration, the server has no problem redirecting the above URL to:<\/p>\n<p>http:\/\/www.mysite.com\/test.html?param=1<\/p>\n<p>In a non-working configuration, Apache simply returns a 404 error. Not cool!<\/p>\n<p>After scouring the web for a few hours, i came across a knowledgeable fellow who really put a dent in this problem. I wish I could remember the link, to give him proper credit.<\/p>\n<p>Essentially, he created two Rewrite Conditions to locate these encoded characters, allow us to Rewrite appropriately:<\/p>\n<p><code>RewriteCond %{THE_REQUEST} ^[A-Z]+\\ \/([^?\\ ]*\\?[^%\\ ]*\\%(25)*(3[Dd]|26)[^\\ ]*)\\ HTTP\/ [OR]<br \/>\n\tRewriteCond %{THE_REQUEST} ^[A-Z]+\\ \/(([^%\\ ]*\\%(25)*([^3].|.[^Ff]))*[^%\\ ]*\\%(25)*3[Ff][^\\ ]*)\\ HTTP\/<br \/>\n\t<\/code><\/p>\n<p>The one missing link was a proper <em>RewriteRule<\/em>. I cam up with the below, which seems to work in all of my test cases. Essentially, replacing the %3F with a ?.<\/p>\n<p><code>RewriteRule ^([^\\%]+) http:\/\/www.mysite.com$1 [R=301,L]<br \/>\n\t<\/code><\/p>\n<p>Again, I have a feeling this is a terribly hacky approach to a simple Apache misconfiguration. But, for those of use who can&#39;t Google 50 search terms per minute to find a solution, the above is pretty close!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This happens on only one of my servers, and I haven&#39;t been able to nail down the problem. It feels like a configuration related issue,&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[77,41],"tags":[118,150],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/476"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=476"}],"version-history":[{"count":2,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/476\/revisions"}],"predecessor-version":[{"id":479,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/476\/revisions\/479"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}