Hi,
my site has problems handling soft 404-errors. E.g. if you call
http://www.lehrerfreund.de/schule/1s/i-am-a-malformed-title-entry-aisjdfiji (there is no entry with the malformed title-entry I use) the user gets correctly directed to the 404-page ( http://www.lehrerfreund.de/schule/404 ), because in my 1s-template I use this code:
{if no_results}{redirect="schule/404"}{/if}
{if segment_5!=""}{redirect="schule/404"}{/if}also in the htaccess the 404-document is defined as 404:
ErrorDocument 404 /schule/404But as far as I can see the 404-page does not generate a 404-header. Here some shortened headers:
<a href="http://www.lehrerfreund.de/schule/404">http://www.lehrerfreund.de/schule/404</a>
GET /schule/404 HTTP/1.1
Host: <a href="http://www.lehrerfreund.de">http://www.lehrerfreund.de</a>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Cookie: exp_last_visit=1036577168; exp_last_activity=1351937847; exp_tracker=a:5:{i:0;s:10:"schule/404";i:1;s:38:"schule/1s/sich-bewerben/3133/undefined";i:2;s:10:"schule/404";i:3;s:38:"schule/1s/sich-bewerben/3133/undefined";i:4;s:10:"schule/404";}; __utma=37294909.360438832.1351938294.1351938294.1351938294.1; __utmb=37294909.8.10.1351938294; __utmc=37294909; __utmz=37294909.1351938294.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __gads=ID=adf4ac625e79d3f7:T=1351938623:S=ALNI_May7GhPPzMp0t1XyOb3ToU3Uz9IEg
If-Modified-Since: Sat, 03 Nov 2012 10:17:27 GMT
HTTP/1.1 200 OK
Date: Sat, 03 Nov 2012 10:20:24 GMT
Server: Apache/2.2.16 (Debian)
X-Powered-By: PHP/5.3.3-7+squeeze13I think the answer should be 404, not 200.
According to http://joviawebstudio.com/index_ee.php/blog/guide_to_404_pages_with_expressionengine/ (chapter “harden up your soft 404”) I set this code in the very begining of my 404-template:
<?php
$this->EE->output->set_header("HTTP/1.0 404 Not Found");
?>
I think this should throw a 404, as described in the annotations on the linked page:
Here’s a little-known gotcha, because we’ve created a 404 page within ExpressionEngine, in some cases, the page technically is not a “page not found”, it is found. For example, with the technique of requiring entries and embedding the 404 page if no results are found, the server sends out a status 200, or “OK” instead of status 404, “page not found”. This normally doesn’t matter to the end user, but to search engines and other robots, it means quite a bit.
The solution is simple here. You must enable PHP for your 404 template, then place the following code at the top of your 404 page:
My question is, if there is something wrong in my setup or in my interpretation.
Thanks in advance!