尝试使用 ErrorDocument 处理请求时遇到 404 Not Found 错误

未知人员

我正在尝试向我的网站添加 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

此外,尝试使用ErrorDocument处理请求时遇到404未找到错误。

尝试使用 ErrorDocument 处理 symfony 5 中的请求时遇到 500 Internal Server Error 错误

使用.htaccess为某些文件类型设置Web服务器处理404错误(ErrorDocument 404 +重写规则)

尝试使用 Chart.js 显示图表时出现 404 Not Found 错误

尝试上传文件时出现 404 not found 错误节点 js

错误:在单击提交按钮以提交消息时处理请求的 ErrorDocument

使用 NPM 发布包时出现 GitLab '404 Not Found' 错误

使用Facebook Graph API时遇到错误-会话:尝试为具有待处理请求的会话请求新权限

尝试使用Reddit API和RedditSharp包装器在帖子上设置样式时遇到404错误

尝试将Java应用程序推送到Cloud Foundry时出现404 Not Found错误消息

尝试从路线检索某些数据时,如何解决404 not found错误?

尝试使用 RequestMapping 访问 html 页面时出现 404 错误

尝试发送 POST 请求时收到 404 错误

使用 `genius` 包获取歌词时出现 `Not Found (HTTP 404)` 错误

尝试协商时出现SignalR 404错误

尝试升级时出现404错误

尝试使用php框架时遇到错误

当路由存在时,我收到 404 not found 错误

尝试通过Angular中的服务发布请求时,错误请求404

Django:尝试在网址中使用Slug时出现404错误

尝试在 php 中使用 .htaccess 创建漂亮的 url 时出现错误 404

尝试使用Angular 6和Spring Boot登录时出现404错误

React JS - 404 - 尝试使用 json API 时(未找到)错误

尝试在 express.js 框架中本地使用 Fontawesome 字体时出现 404 错误

尝试使用事件处理程序winform从DataGridView读取时遇到错误

尝试使用“请求”模块时导入错误

错误404 - 使用@RestController Get请求 - SpringBoot

错误404,尝试调用api端点时找不到请求的url

尝试向TFS发送REST请求时,为什么会出现404错误?