Reputation:
I want a 404 page to write The page at "/fake/path/index.php" could not be found
, but it
always writes The page at "/404/index.php" could not be found
. (/404/index.php is the error
document). How can I access the path that was being accessed (/fake/path/index.php) instead? (I am using .htaccess ErrorDocument 404)
.htaccess:
ErrorDocument 404 /404/
/404/index.php:
<html>
<head>
<meta charset="UTF-8" />
<title>404 Error</title>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script src="/js/jquery-2.0.3.js"></script>
<script src="/js/jquery-ui-1.10.3.js"></script>
<script src="/js/script.js"></script>
</head>
<body>
<div id="content">
<h1 id="page_title" style="text-align: center;">404 Error - Not Found</h1>
<span style="font-size: 14px; color: black;">
The page at "<a href="$dir"><?php echo $_SERVER['PHP_SELF']; ?></a>" could not be found. Possible causes of this are:
</span>
</div>
</body>
</html>
Upvotes: 0
Views: 1341
Reputation: 13128
Your issue is that you're querying $_SERVER['PHP_SELF'];
which will return /404/index.php
as that is the file name.
What you want is to use REQUEST_URI
:
<span style="font-size: 14px; color: black;">
The page at "<a href="$dir"><?php echo $_SERVER['REQUEST_URI']; ?></a>" could not be found. Possible causes of this are:
</span>
Upvotes: 1