After moving my website to a webhost which uses LiteSpeed it seems PHP header is ignored.
I have tried these variations:
$s = "HTTP/1.1 404 Not Found";
$s = "HTTP/1.0 404 Not Found";
$s = "Status: 404 Not Found";
$s = $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found';
followed by
header($s)
But on LiteSpeed these all seem to be ignored.
- Is there any option in LiteSpeed I can turn off to get Apache compatible behavior? I have access to cPanel and .htaccess
- Any other possible explanation and/or solution?
NOTES:
- Problem happens on both https and http variations
- The page returning 404 is a page used for handling mod_rewrites (so for URL queries where no valid content is found in database, 404 http response code should be returned)
- Problem also happens on another domain of mine placed the server (using a popular PHP forum solution with a mod_rewrite based plugin for nice looking URLs)
- The mod_rewrites themselves work fine.
- The header() call is also ignored on non-mod_rewrite URLs such as test?id=2
- Both sites work fine on those Apache servers I have tried through time (at least two different Apache webhosts + my localhost)
Also, on both websites I have disable LiteSpeed caching in my .htaccss file
<IfModule LiteSpeed>
RewriteRule .* - [E=Cache-Control:no-cache]
</IfModule>
The problem can be duplicated by creating a simple
test.php file like this
<?php
$s = $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found';
header($s);
echo 'test';
?>
And then try request test?id=2