【发布时间】:2020-06-06 19:08:09
【问题描述】:
我正在尝试将 404 错误页面添加到我的网站,但是,当我尝试访问它时出现此错误。
Not Found
The requested URL /asd.html was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
我的 .htaccess 页面仅包含以下行:
ErrorDocument 404 /404-page.php;
而且下面的 404-page.php 文件和 .htaccess 文件在同一个目录下,所以我不确定为什么会这样。
<?php
require "header.php";
?>
<main>
<h2>404 - Page not found</h2>
<p>The page you are looking for was not found, if this is an error please contact administration.</p>
</main>
<?php
require "footer.php";
?>
我试过只为 404 使用 html 页面,以及将页面上传到主机,但都没有成功。
主机的目录去:
/
public_html
404-page.php
.htaccess
【问题讨论】:
-
您是否尝试过检查
htaccess是否已被解析,例如通过在其中放入无效字符串? -
@NicoHaase 我只是尝试放置一个无效的路径,然后返回
命令的一部分,例如路径/404-page.php