WordPress 自定义数据库错误页

当你的 WordPress 站点出现数据库错误的时候,默认会看到这样的页面:

images

你也可以自定义错误页,首先在 “wp-content” 文件夹创建一个 db-error.php 文件,在里边放上这样的代码:

<?php
/**
 *WordPress 自定义数据库错误页
 *http://www.endskin.com/database-error-page/
*/
header( 'HTTP/1.1 503 Service Temporarily Unavailable' );
header( 'Status: 503 Service Temporarily Unavailable' );
header( 'Retry-After: 600' );
?>
<!DOCTYPE HTML>
<html>
<head>
 <meta charset="UTF-8">
 <title>数据库错误</title>
</head>
<body>
 <h1>数据库错误</h1>
 <p>自定义数据库错误页</p>
</body>
</html>

这样就可以自定义数据库错误页了。

images

事实上,这个自定义的错误页实际上是一个 Drop-in 高级插件,了解什么是 Drop-in 高级插件:关于WordPress的Drop-in高级插件

原文来自http://www.endskin.com/database-error-page/