ErrorDocument 404/404.php 在 PHP 中的 .htaccess 文件中不起作用 [英] ErrorDocument 404 /404.php is not working in .htaccess file in PHP

查看:36
本文介绍了ErrorDocument 404/404.php 在 PHP 中的 .htaccess 文件中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在根目录中有一个 .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:

未找到

在此服务器上找不到请求的 URL/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 文件夹根目录的绝对路径,而是文件系统的根目录.这可能取决于您的配置,例如/home/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.

这篇关于ErrorDocument 404/404.php 在 PHP 中的 .htaccess 文件中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆