【发布时间】:2011-06-16 01:14:36
【问题描述】:
使用 Nginx 0.8.54 :我设置 PHP 错误页面对某些链接进行重定向,对其他链接进行 404 重定向,并显示自定义 HTML 正文。 nginx
server {
error_page 404 = /err/error.php?error=404;
}
error.php
<?php
if( $_SERVER['REQUEST_URI'] == "/blah" ){
header('Status: 301 Moved Permanently');
header('location: http://localhost/ ');
}else
header('Status: 404 Not Found');
echo 'This is a custom Error Page';
?>
Nginx 进行重定向没有问题,但对于 404 自定义页面,Nginx 发送 404 标头并显示默认 Nginx 页面而不是“这是自定义错误页面”文本。
【问题讨论】:
标签: php error-handling nginx