使用.htaccess在同一服务器上的另一个域上查找错误页面

时间:2018-10-10 21:24:35

标签: php .htaccess

我用以下代码制作了一个自定义php错误页面:

/*T is Foo<U> for any U*/

我的服务器上大约有50个域,我想使用这些自定义错误页面,但是当我将.htaccess文件编辑为:

<?php 
$status = $_SERVER['REDIRECT_STATUS'];
$codes = array(
       400 => array('400 Bad Request', 'The request could not be understood by the server due to malformed syntax.'),
       401 => array('401 Unauthorized', 'The request requires user authentication.'),
       403 => array('403 Forbidden', 'The server has refused to fulfill your request.'),
       404 => array('404 Not Found', 'The document/file requested was not found on this server.'),
       405 => array('405 Method Not Allowed', 'The method specified in the Request-Line is not allowed for the specified resource.'),
       408 => array('408 Request Timeout', 'Your browser failed to send a request in the time allowed by the server.'),
       500 => array('500 Internal Server Error', 'The request was unsuccessful due to an unexpected condition encountered by the server.'),
       501 => array('501 Not Implemented', 'The server does not support the functionality required to fulfill the request.'),
       502 => array('502 Bad Gateway', 'The server received an invalid response from the upstream server while trying to fulfill the request.'),
       504 => array('504 Gateway Timeout', 'The upstream server failed to send a request in the time allowed by the server.'),
);

$title = $codes[$status][0];
$message = $codes[$status][1];
if ($title == false || strlen($status) != 3) {
       $message = 'Please supply a valid status code.';
}
    echo $title; ?>

ErrorDocument 404 /../www/error.php

我没有爱,当我这样输入主域名时

ErrorDocument 404 /../public_html/error.php

它只是重定向。

这怎么办?谢谢。

0 个答案:

没有答案