目前我收到一个404错误,但它不会重定向到404.php
下面是我的index.php的内容:
<?
header("HTTP/1.1 404 Not Found");
exit;
?>
<html>
<head>
<title>Index</title>
</head>
<body>
<h1>Index</h1>
<p>This is the homepage, but I'd like it to go to 404.php!</p>
</body>
</html>下面是404.php:
<html>
<head>
<title>404</title>
</head>
<body>
<h1>Page Not Found!</h1>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
<p>This is my test custom 404 page!</p>
</body>
</html>下面是.htaccess:
ErrorDocument 404 /Users/me/folder/mamp/404.php/Users/me/folder/mamp/404.php表示MAMP首选项中的根文档文件夹。
我还尝试了.htaccess中/404.php的相对路径和http://localhost:8888/404.php的URL。到目前为止,所有的结果都是一样的,一个白色的页面,发出了一个404但没有重定向。
从我的阅读来看,所有这些结合在一起应该会起到作用;似乎仍然遗漏了一些东西。
发布于 2014-09-12 02:02:29
您在此处使用ErrorDocument是错误的:
ErrorDocument 404 /Users/me/folder/mamp/404.php您需要使用DocumentRoot中的相对路径或使用以http开头的完整URL。所以使用:
ErrorDocument 404 /404.php或
ErrorDocument 404 http://domain.com/404.phphttps://stackoverflow.com/questions/25793755
复制相似问题