【问题标题】:Strange .htaccess ErrorDocument Error奇怪的.htaccess ErrorDocument 错误
【发布时间】:2013-01-04 10:59:38
【问题描述】:

我的 .htaccess 文件中有以下行,该文件位于我的 PC 上 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 语法并包含完整链接时,即制作它:

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 

令人毛骨悚然,嗯?那么有人可以帮我告诉我发生了什么事吗?

【问题讨论】:

  • 只是为了确保....404.html 位于您的网络根目录的最顶端,对吗?
  • 根目录是G:/xampp/htdocs/,我的404.html是G:/xampp/htdocs/project/public_html/
  • / 引用了 Web 根目录,所以我不确定您为什么希望 Apache 神奇地找到它。尝试将路径更改为 /project/public_html/404.html 或将 404 移动到 /xampp/htdocs/
  • / references the web root, so I'm not sure why you would expect Apache to magically find that 我在想文件夹 .htaccess 文件的 / 引用在其中。我尝试了您的解决方案,它奏效了!谢谢,您能否将其制定为答案并发布,以便我接受..
  • 当然:)。现在已经这样做了

标签: apache .htaccess


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2016-10-12
    • 1970-01-01
    • 2017-10-19
    • 2023-03-28
    • 2014-11-26
    • 2012-10-19
    • 1970-01-01
    • 2010-11-17
    相关资源
    最近更新 更多