奇怪的.htaccess ErrorDocument错误

时间:2013-01-04 10:59:39

标签: apache .htaccess

我的.htaccess文件中有以下行,该文件位于我的电脑G:/xampp/htdocs/project/public_html/.htaccess

ErrorDocument 404 /404.html

因此,当我输入任何无效地址时,例如http://localhost/project/public_html/blabla,会显示以下消息:

Not Found

The requested URL /project/public_html/blabla was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 Server at localhost Port 80

但这不是我的404.html页面!

但是当我编辑ErrorDocument语法并包含完整链接时,即make it:

ErrorDocument 404 http://localhost/project/public_html/404.html

但是这会将非现有链接正确地重定向到404.html,但重定向不是我想要的!我想要一个简单的404错误页面!

另外一个奇怪的事情是,当我从.htaccess文件中完全删除该行时,错误会更改为:

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.
Error 404
localhost
1/4/2013 4:27:46 PM
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 
令人毛骨悚然,是吗?那么有人可以帮助我并告诉我最新情况吗?

1 个答案:

答案 0 :(得分:1)

/引用了网络根目录,因此您的路径不太合理。将文件移动到Web根目录,或更改路径以反映相对于Web根目录的路径。 (将文件移至/xampp/htdocs,或将路径更改为/project/public_html/404.html。)