https://redmine.lighttpd.net/https://redmine.lighttpd.net/favicon.ico?13667327412008-11-25T12:24:52Zlighty labsLighttpd - Bug #1828: REDIRECT_STATUS == 200 on 404 redirecthttps://redmine.lighttpd.net/issues/1828?journal_id=51012008-11-25T12:24:52Zbestis
<ul></ul><p>Also I would like to see possibility to change that in lua (have searched but haven't found it).<br />So when stat fails in lua it could be set to 404 when making a redirect there.</p>
<pre>
attr = lighty.stat(lighty.env['physical.path'])
if (not attr) then
-- file still missing. pass it to the fastcgi backend
lighty.env["uri.path"] = "/index.php"
lighty.env["physical.rel-path"] = lighty.env["uri.path"]
lighty.env["request.orig-uri"] = lighty.env["request.uri"]
lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"]
-- like this or something:
lighty.env["request.status"] = 404
end
</pre> Lighttpd - Bug #1828: REDIRECT_STATUS == 200 on 404 redirecthttps://redmine.lighttpd.net/issues/1828?journal_id=75572011-08-12T02:26:37ZMozai
<ul></ul><p>With PHP you can work around this bug by putting this at the top of your script:<br /><pre>
<?php header(‘HTTP/1.0 404 Not found’); ?>
</pre><br />Something similar can be done for CGI. People wishing to use static html error messages <del>are out of luck.</del></p>
<p>EDIT: I read the <a class="wiki-page" href="https://redmine.lighttpd.net/projects/lighttpd/wiki/FrequentlyAskedQuestions">FrequentlyAskedQuestions</a>; now I have an answer for those who are not using PHP. For custom error messages, one should use "server.errorfile-prefix" instead, and have files named "404.html", "403.html", "500.html" etc in that directory.</p>
<p>I was confused by the name "server.error-handler-404" since I thought it was for reporting 404 errors, but the FAQ tells me it's actually for creating new pages to replace 404 errors.</p> Lighttpd - Bug #1828: REDIRECT_STATUS == 200 on 404 redirecthttps://redmine.lighttpd.net/issues/1828?journal_id=76082011-10-04T04:08:07ZMalvineous
<ul></ul><p>Unfortunately your solution doesn't address the problem. Your code returns a HTTP 404 error to the browser, but the bug is about detecting the error code that caused your script to be called in the first place.</p>
<p>For example if you have server.error-handler-404="index.php" and then you visit <a class="external" href="http://yoursite/index.php">http://yoursite/index.php</a> followed by <a class="external" href="http://yoursite/badpage">http://yoursite/badpage</a> both times index.php will be called, but $_SERVER['REDIRECT_STATUS'] will be 200 both times, so you don't know whether you're being called directly or as the result of a 404 redirect.</p>
<p>Under Apache, the second URL will set $_SERVER['REDIRECT_STATUS'] to 404 so you know the script is being called as the result of a 404 redirect.</p>
<p>Some content management systems use this for 'friendly URLs', so these systems cannot run correctly under lighttpd.</p> Lighttpd - Bug #1828: REDIRECT_STATUS == 200 on 404 redirecthttps://redmine.lighttpd.net/issues/1828?journal_id=89552016-02-28T23:57:21Zgstrauss
<ul></ul><p>Submitted <a class="external" href="https://github.com/lighttpd/lighttpd1.4/pull/35">https://github.com/lighttpd/lighttpd1.4/pull/35</a> to set REDIRECT_STATUS to HTTP status code for access by server.error-handler-404. Currently, the only values will be 403 or 404, as those are the HTTP status codes intercepted by server.error-handler-404.</p> Lighttpd - Bug #1828: REDIRECT_STATUS == 200 on 404 redirecthttps://redmine.lighttpd.net/issues/1828?journal_id=92392016-03-30T15:47:49Zgstrauss
<ul><li><strong>Target version</strong> set to <i>1.4.40</i></li></ul> Lighttpd - Bug #1828: REDIRECT_STATUS == 200 on 404 redirecthttps://redmine.lighttpd.net/issues/1828?journal_id=94592016-04-25T06:00:15Zgstrauss
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Fixed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>Applied in changeset <a class="changeset" title="[core] set REDIRECT_STATUS to error_handler_saved_status (fixes #1828) set REDIRECT_STATUS to co..." href="https://redmine.lighttpd.net/projects/lighttpd/repository/14/revisions/5492063f356755e276344427d4ef8ad2541d3c8d">5492063f356755e276344427d4ef8ad2541d3c8d</a>.</p>