我要檢查渡過頁是有錯誤,如果錯誤是在那裏,我必須重定向到一個默認的頁面像error.php通過php重定向到另一個頁面?
我曾與下面的鏈接嘗試,但我不能得到的結果
改變我的.htaccess
ErrorDocument 400 /errors.php
ErrorDocument 403 /errors.php
ErrorDocument 404 /errors.php
ErrorDocument 405 /errors.php
ErrorDocument 408 /errors.php
ErrorDocument 500 /errors.php
ErrorDocument 502 /errors.php
ErrorDocument 504 /errors.php
我errors.php代碼
<?php
$urPath= $_SERVER['PHP_SELF'];
$fle =basename($urPath);
$finstr =str_replace("$fle","","$urPath");
$status = $_SERVER['REDIRECT_STATUS'];
$codes = array(
400 => array('400 Bad Request', 'The request cannot be fulfilled due to bad syntax.'),
403 => array('403 Forbidden', 'The server has refused to fulfil your request.'),
404 => array('404 Not Found', 'The page you requested was not found on this server.'),
405 => array('405 Method Not Allowed', 'The method specified in the request 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.'),
502 => array('502 Bad Gateway', 'The server received an invalid response while trying to carry out 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 HTTP status code.';
}
echo '<h1>Hold up! '.$title.' detected</h1>
<p>'.$message.'</p>';
?>
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="<?php echo $finstr;?>css/token-input.css" rel="stylesheet" />
<link rel="stylesheet" href="<?php echo $finstr;?>css/jquery.mobile-1.2.0.min.css" />
<link rel="stylesheet" href="<?php echo $finstr;?>css/app-reset.css" />
<link rel="stylesheet" href="<?php echo $finstr;?>css/jquerymobilecrm.min.css" />
<link rel="stylesheet" href="<?php echo $finstr;?>css/jqm-datebox.css" />
<link rel="stylesheet" href="<?php echo $finstr;?>css/dcr_css.css" />
<link rel="stylesheet" href="<?php echo $finstr;?>css/jQueryValidationEngine.css" />
<script src="<?php echo $finstr;?>js/jquery-1.8.1.min.js"></script>
<script src="<?php echo $finstr;?>js/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?php echo $finstr;?>js/jquery.tokeninput.js"></script>
<script src="<?php echo $finstr;?>js/jquery.mobile-1.2.0.min.js"></script>
<script src="<?php echo $finstr;?>js/logout.js"></script>
<script type="text/javascript" src="<?php echo $finstr;?>js/jqm-datebox.core.js"></script>
<script type="text/javascript" src="<?php echo $finstr;?>js/jqm-datebox.mode.datebox.js"></script>
<script type="text/javascript" src="<?php echo $finstr;?>js/jQueryValidationEngine-en.js"></script>
<script type="text/javascript" src="<?php echo $finstr;?>js/jQueryValidationEngine.js"></script>
<script type="text/javascript" src="<?php echo $finstr;?>js/dateValidation.js"></script>
<style type="text/css">
.data-clear{
height:35px;
width:100%;
}
</style>
<?php //require_once"header.php";?>
</head>
<body>
<div data-role="page" id="addDialysis">
<div data-role=header data-theme="a" data-position="fixed" style="height:40pt;">
<h1 align="left" style="color: white;margin-top: 10pt;">Error Page</h1>
<a href="home.php" data-icon="home" data-role="button" data-theme="reset" rel="external" style="margin-top:5pt;"><span style="padding-left: 14px;color: white;">Home</span></a>
</div>
<div data-role=fieldcontain>
<div style="margin-left:45%"><p>Error Occurred !!!</p></div>
</div>
</div>
</body>
</html>
建議我任何的想法,在此先感謝..
運行代碼時究竟發生了什麼? –
它顯示默認錯誤頁面... –
你是否在磁盤上以及在你的問題拼寫'.htaccess'文件不正確? – RiggsFolly