简体   繁体   English

创建错误页面并修改htaccess?

[英]Create error pages and modify htaccess?

Iam trying to create error pages for my website, I created an .htaccess file with the following code: 我试图为我的网站创建错误页面,我使用以下代码创建了一个.htaccess文件:

ErrorDocument 403 /403.htm ` ErrorDocument 403 /403.htm

ErrorDocument 404 /404.htm

I also created the html files, I uploaded it in the root directory but it doesn't work. 我还创建了html文件,我将其上传到了根目录,但无法正常工作。

Coould anyone tell me if I am doing anything wrong? 有人可以告诉我我做错了什么吗?

Thanks in advance 提前致谢

Blockquote 块引用

First, I would try something like adding this directive, and testing a 404 to see if it works: 首先,我将尝试添加此指令,然后测试404以查看其是否有效:

ErrorDocument 404 "Sorry, no file here"

If you don't get that error, then in all likelihood your .htaccess file isn't being processed. 如果未收到该错误,则很可能未处理您的.htaccess文件。 You need to make sure that it's enabled on your server, etc. It is also possible that your ErrorDocument directive is specified somewhere that it isn't being read for the context where you are testing. 您需要确保已在服务器等上启用它。也有可能在您要测试的上下文中未读取它的某个位置指定了ErrorDocument指令。

If you do get that error, the next thing I would do is make sure that your error documents are where you think they are. 如果确实收到该错误,那么我接下来要做的就是确保您的错误文档在您认为的正确位置。 You mention that you uploaded them to the root directory of your project, so I would try browsing to them and see what happens. 您提到您已将它们上载到项目的根目录,因此我将尝试浏览到它们并查看会发生什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM