开发者

Header status not working in php cgi

开发者 https://www.devze.com 2023-02-20 16:47 出处:网络
Setting the Status header is not working in PHP CGI. I am using PHP on the IIS webserver. header(\'HTTP/1.1 404 Not Found\');

Setting the Status header is not working in PHP CGI. I am using PHP on the IIS webserver.

header('HTTP/1.1 404 Not Found');
header('Status: 4开发者_运维百科04 Not Found');

Do you have any ideas why this might not be working?


Simply sending a Status header from PHP does not make your webserver return it's default error page. You need to do this yourself. Either you generate the contents for an error page like you would render any other page, or you redirect to another URL and configure your webserver to display an error page for you.

For example, you could do this in PHP:

header('Location: /404.html');

Then configure your webserver to serve 404.html as a 404 error.

0

精彩评论

暂无评论...
验证码 换一张
取 消