我想要一个404页面来编写The page at "/fake/path/index.php" could not be found
,但它
总是写The page at "/404/index.php" could not be found
。 (/404/index.php是错误
文献)。如何访问正在访问的路径(/fake/path/index.php)? (我正在使用.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>
答案 0 :(得分:1)
您的问题是,您要查询$_SERVER['PHP_SELF'];
将返回/404/index.php
,因为这是文件名。
您想要的是使用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>