我正在尝试向我的网站添加 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
我修正了错误,原来是因为我有一个 ';' 在行尾,这是它不工作的原因。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句