It probably does not 'redirect' you. Look at the URL in the address window next time your site throws a 404.
1. Create a file, call it 404.php (can name it anything, just easier to keep track of if you name it for the error). Should be a php file.
2. Make the page pretty, etc. You can access the URI (relative to document root ) by using
Code:
<?php echo $_SERVER[ 'REQUEST_URI' ] ?>
Example of full page...
HTML Code:
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Not here, I looked for it.</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 4em 4em;
margin: 4em auto 0 auto;
border: 2px solid #bbb;
border-right-color: #777;
border-bottom-color: #888;
}
h1 { font-size: 110%; color: #f00; line-height: 1.5em; }
h2 { font-size: 90%; color: #000; line-height: 1.5em; }
h3 { font-size: 80%; color: #333; line-height: 1.5em; }
h4 { font-size: 70%; color: #666; line-height: 1.1em; }
</style>
</head>
<body>
<div class='dialog'>
<h1>__________ 404 __________</h1>
<p>
<h2>Sorry, you must have dialed a wrong number</h3>
<h3>The page you requested , <?php echo $_SERVER[ 'REQUEST_URI' ] ?> , cannot be found at this moment.</h3>
<h4>I looked for it. Honest. It's not there</h4>
</p>
</div>
</body>
</html>
3. Add to .htaccess (I keep my custom error pages in a error/ subdirectory.)
Code:
ErrorDocument 404 /error/404.php