.htaccess 跨浏览器

发布于 2024-09-05 13:08:15 字数 400 浏览 3 评论 0原文

我尝试在 Linux 服务器上使用 .htaccess 文件加载 404 错误的自定义错误文档,该页面获取当前页面 URL,然后根据从 db 检索到的 id 重定向到另一个站点(从数据库检索)网址。

当前的错误文档存储在这里:

/error_docs/ 中已有的 HTML 文件之外,我无权上传任何内容

- 除了/HTTPDocs/301redir.php 是 .htaccess 文件所在的站点根目录。

我使用以下内容加载 301redir.php 页面作为错误文档,该文档在 FF 中有效,但在其他浏览器中无效。

使用 .htaccess 的ErrorDocument 404 /310redir.php

是我更改此设置的唯一真正选择,有没有办法解决此问题并使其适用于所有浏览器?

Im trying to load a custom error document for a 404 error using a .htaccess file on a linux server, the page gets the current page URL then redirects to another site (which is retrieved from a db) based on an id it retrieved from the URL.

The current error documents are stored here:

/error_docs/
- i dont have permission to upload anything other than the HTML files that are already in there

/HTTPDocs/301redir.php
is the site root where the .htaccess file is.

i have used the following to load the 301redir.php page as the error doc, which works in FF but no other browsers.

ErrorDocument 404 /310redir.php

using .htaccess is my only real option for changing this, is there a way to get around this issue and make it work across all browsers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

┊风居住的梦幻卍 2024-09-12 13:08:16

也许您的文件太小,请参阅以下摘录自 apache 文档< /a>:

微软 Internet Explorer (MSIE)
会默认忽略
服务器生成的错误消息
它们“太小”并且可以替代
它自己的“友好”错误消息。这
大小阈值取决于
错误类型,但一般来说,如果您
让你的错误文档大于
512字节,那么MSIE将显示
服务器生成的错误而不是
掩盖它。更多信息是
可在 Microsoft 知识库中找到
文章 Q294807。

Maybe your file is too small, see the following excerpt from the apache docs:

Microsoft Internet Explorer (MSIE)
will by default ignore
server-generated error messages when
they are "too small" and substitute
its own "friendly" error messages. The
size threshold varies depending on the
type of error, but in general, if you
make your error document greater than
512 bytes, then MSIE will show the
server-generated error rather than
masking it. More information is
available in Microsoft Knowledge Base
article Q294807.

红ご颜醉 2024-09-12 13:08:16

这应该可以正常工作,尝试输入完整的 URL http://www.yourdomain.com/301redir.php< /a>

我还注意到你说 310redir.php 是你的例子,但你的描述中是 301redir.php (注意 310 和 301)。

另外,如果您正在执行 404,请不要忘记添加 header("HTTP/1.1 404 Not Found");

That should work fine, try putting the full URL http://www.yourdomain.com/301redir.php

I also note that youu said 310redir.php is your example but 301redir.php in your description (note 310 and 301).

Also don't forget to add header("HTTP/1.1 404 Not Found"); if you are doing a 404

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