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

查看:339
本文介绍了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:

未找到

所请求的网址/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.

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

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