自404 Apache的错误问题 [英] Custom 404 error issues with Apache

查看:343
本文介绍了自404 Apache的错误问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的网站创建一个自定义404错误。我使用的XAMPP在Windows上测试了这一点。

I am trying to create a custom 404 error for my website. I am testing this out using XAMPP on Windows.

我的目录结构如下:

error\404page.html
index.php
.htaccess

我的.htaccess文件的内容是:

The content of my .htaccess file is:

ErrorDocument 404 error\404page.html

这将产生以下结果:

然而,这是行不通的 - 它是什么做的方式是斜线或如何,我应该引用错误文件

However this is not working - is it something to do with the way the slashes are or how I should be referencing the error document?

网站的网站文件驻留在一个在Web根目录的子文件夹,如果说有什么区别,我应该如何参考?

site site documents reside in a in a sub folder of the web root if that makes any difference to how I should reference?

感谢您先进的。

当我更改该文件是

ErrorDocument 404 /error/404page.html

我收到这不是什么是HTML文件里面我已经把下面的错误消息 - 但它是不同的东西如上面的:

I receive the following error message which isn't what is inside the html file I have linked - but it is different to what is listed above:

推荐答案

的ErrorDocument 指令,当提供本地URL路径,预计将在 的DocumentRoot 。在你的情况,这意味着实际路径的ErrorDocument

ErrorDocument 404 /JinPortfolio/error/404page.html

当你在你的第二次尝试纠正它,原因你看到的页面,而不是因为的http://localhost/error/404page.html 不存在,因此对那里正在查找错误处理文件404错误的位。

When you corrected it in your second try, the reason you see that page instead is because http://localhost/error/404page.html doesn't exist, hence the bit about there being a 404 error in locating the error handling document.

这篇关于自404 Apache的错误问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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