ErrorDocument的404 /404.php不工作在PHP .htaccess文件文件、工作、ErrorDocument、htaccess

2023-09-02 20:34:45 作者:离终 -

我在根目录下的的.htaccess 文件,也404.php文件存在。内容我的.htaccess 文件是:

I have a .htaccess file in the root directory and also 404.php file there. Content of my .htaccess file is:

ErrorDocument 404 /404.php 

但是,当我误拼写我的网址, 404.php 是不开放。相反,我得到以下信息:

But when I am mis-spelling my url, 404.php is not opening. Instead I am getting following message:

未找到

所请求的网址/mywebsite/ites.php在此服务器上找到。

The requested URL /mywebsite/ites.php was not found on this server.

此外,一个404 Not Found错误,而试图遇到   使用ErrorDocument来处理请求。

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

但是,当我试图的ErrorDocument 404 google.com ,它的工作。

But when I tried ErrorDocument 404 google.com, it worked.

推荐答案

我会巩固我的意见,这样的回答:

I'll consolidate my comments to this answer:

当设置...

ErrorDocument 404 /404.php

/404.php 路径未必是绝对路径htdocs文件根目录,而是你的文件系统的根目录。这可能是,根据您的配置,例如 /主页/ htdocs中/ 等等。

the /404.php path may not be the absolute path to your htdocs folder root but instead the root of your filesystem. This may be, based on your configuration, e.g. /home/htdocs/ or ~ and so on.

那么什么人需要做的是找出绝对路径并进行相应设置。

So what one need to do is find out the absolute path and set it accordingly.