wordpress下有一个wp_die()函数。只要出错,比如数据库错误,就错输出一个包含错误信息的页面。基本输出代码是这样的。
[code]<?php
@header("HTTP/1.0 500 Internal Server Error" , true , 500);
@header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
@header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
@header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
@header( 'Pragma: no-cache' );
@header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head><body>
出错啦!
</body>
</html>[/code]
我把这个代码本地测式,在IE下只能看到IE默认的500错误页面。但放在wordpress下的wp-admin目录,就可以看到“出错啦!”三个字。我仔细找了该目录下,似乎没有.htaccess文件,我想请问wordpress是怎么做到在输出:“header("HTTP/1.0 500 Internal Server Error" , true , 500);”头后,IE显示的不是默认的500错误页面,而是自己定义的信息呢?如果用了.htaccess,为什么我找不到该文件,我在cmd里用 dir /a(显示所有文件,包括隐藏文件),仍然没看到它的影子。有除了.htaccess定义错误页面的其它方法么?

解决方案 »

  1.   


    <?php
    @header("HTTP/1.0 500 Internal Server Error" , true , 500);
    @header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
    @header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
    @header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
    @header( 'Pragma: no-cache' );
    @header( 'Content-Type: text/html; charset=utf-8' );
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title> new document </title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="generator" content="editplus" />
    <meta name="author" content="" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    </head><body>
    出错啦!
    </body>
    </html>
      

  2.   

    httpd.conf里也可以定义
    ErrorDocument 500  /xxx.xxx
      

  3.   


    出现的原因是不是有可能是IE的设置原因 : IE-》工具-》Internet 选项-》高级 -》 显示友好URL 去掉 钩