.htaccess 跨浏览器
我尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您的文件太小,请参阅以下摘录自 apache 文档< /a>:
Maybe your file is too small, see the following excerpt from the apache docs:
这应该可以正常工作,尝试输入完整的 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