i have to check weather the page is having error,if error is there i have to redirect to one default page like error.php
I have tried with the following link but i cannot get the result
changes in my .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
my errors.php code
<?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>
suggest me any idea,Thanks in advance..
Advertisement
Answer
Are you working on a local server/localhost?
/errors.php will refer to your base url, e.g. http://localhost/errors.php
. If you are working with a project directory (e.g. http://localhost/project_dir/
), the path to the errors.php-file should be /project_dir/errors.php.
With this change, the code works fine on my system.