404自定义错误模板.htaccess

发布于 2025-01-06 22:10:44 字数 407 浏览 3 评论 0原文

好的,我有一个问题,我的 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北斗星光 2025-01-13 22:10:44

使用 ErrorDocument 时,您指定的文件是相对于 DOCUMENT ROOT 而不是 .htaccess 位置!

编辑:
假设您有 notfound.html 并且希望将其用于文件夹 dir01,您可以在此文件夹中创建一个 htaccess 文件并添加以下内容

ErrorDocument 404    /dir01/notfound.html

:您想在浏览器中访问您的文件(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 folder dir01, you create an htaccess file inside this folder and add this:

ErrorDocument 404    /dir01/notfound.html

If you want to access your file(notfound.html) in browser it would be http://www.example.com/dir01/notfound.html. that's all I could explain!

早乙女 2025-01-13 22:10:44

您可以在 .htaccess 文件中使用以下代码:

RewriteBase /

You can use in your .htaccess file the following code:

RewriteBase /

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文