.htaccess 错误未按预期工作

.htaccess error's not working as intended

我有几个 .php 页面需要 URL 重写,还有一页我没有使用 url 重写。

在我的 .htaccess 文件中,我写了以下内容:

ErrorDocument 404   /Reducation/Aarde/errors/404.php

这适用于我 不是 使用 URL 重写的一页。

然而,当我访问一个 URL 重写的页面并错误地键入 url 时,例如:http://localhost/Reducation/Log-in/Regi 它显示标准 XAMPP 404 错误,而不是我的自定义错误,有没有办法解决这个问题,或者是否有禁用标准 XAMPP 404 消息的方法?

这是显示的错误消息,以及常规 Object not found:

Error 404

localhost
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.6

我试过以下方法:

ErrorDocument 404   /Reducation/Log-in/errors/404.php
"ErrorDocument 404   /Reducation/Log-in/errors/404.php"
ErrorDocument 404 /errors/404.php

我的source.

编辑:我的假设是当我重写 url 时它不起作用,因为路径不匹配 errors

我刚刚测试了我认为它是什么,看来我是对的,它不起作用,因为路径不匹配。有解决办法吗?

要禁用 xampp 404 自定义处理程序,请将此行作为根 htaccess 文件中的第一行:

ErrorDocument 404   default

404 URI 必须是绝对的,即它必须以 http:// 开头或 / 使其相对于 DocumentRoot 并且如果直接输入则完全相同 URL 必须在浏览器中工作。