404自定义错误模板.htaccess
好的,我有一个问题,我的 .htaccess 代码是:
RewriteEngine on
ErrorDocument 404 /notfound.html
并且我在 .htaccess 附近没有找到.html。
为什么它不起作用?我不相信我所看到的。我从这里获取了教程 http://www.htaccessbasics.com/404-custom-error-page/
我只是希望每次访问 www.site.com/ajfasoijfiajsfijaofij 时都能显示 notfound.html 中的内容。
Ok, I have a problem, my .htaccess code is:
RewriteEngine on
ErrorDocument 404 /notfound.html
and I have not found.html near .htaccess.
Why is it not working? I don't believe what I'm seeing. I took the tutorial from here
http://www.htaccessbasics.com/404-custom-error-page/
I just want that every time I access www.site.com/ajfasoijfiajsfijaofij to show what is it in notfound.html.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
ErrorDocument
时,您指定的文件是相对于 DOCUMENT ROOT 而不是.htaccess
位置!编辑:
假设您有
notfound.html
并且希望将其用于文件夹dir01
,您可以在此文件夹中创建一个htaccess
文件并添加以下内容:您想在浏览器中访问您的文件(
notfound.html
),它将是http://www.example.com/dir01/notfound.html
。这就是我能解释的一切!when using
ErrorDocument
, the file you're specifying is relative to DOCUMENT ROOT not.htaccess
location!Edit:
assume you have
notfound.html
and you want to use it for folderdir01
, you create anhtaccess
file inside this folder and add this:If you want to access your file(
notfound.html
) in browser it would behttp://www.example.com/dir01/notfound.html
. that's all I could explain!您可以在 .htaccess 文件中使用以下代码:
RewriteBase /
You can use in your .htaccess file the following code:
RewriteBase /