如何使用.htaccess中的ErrorDocument在浏览器中保留URI? [英] How to keep URI in the browser using ErrorDocument in .htaccess?

查看:79
本文介绍了如何使用.htaccess中的ErrorDocument在浏览器中保留URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.htaccess文件中有一个简单的404错误重定向,如下所示:

I have a simple 404 error redirect in the .htaccess to my script like this:

ErrorDocument 404 https://example.com/error.pl?q=404

但是在重定向中,地址已更改浏览器的地址栏,从错误的地址(执行重定向的地址)到此 https://example.com/error.pl?q=404

But on the redirect the address is changed in the address bar of the browser to this https://example.com/error.pl?q=404 from the wrong address (from which the redirect is performed).

如何在重定向到自定义错误页面时将初始地址保留在浏览器地址栏中?

How to keep the initial address in the browser address bar while redirecting to the custom error page?

您的帮助

推荐答案

使用不带域名的链接:

ErrorDocument 404 /error.pl?q=404




请注意,当您指定一个指向远程
URL的ErrorDocument时(例如,前面带有诸如http之类的方法的任何内容),Apache
HTTP Server会将重定向发送到客户告诉它
在哪里找到文档,e即使文档最终位于同一台
服务器上,也是如此。这有几个含义,最重要的是
客户端将不会收到原始错误状态代码,而
则会收到重定向状态代码。反过来,这会使
网络机器人和其他尝试使用状态代码确定URL是否有效的
的客户端产生混淆。
https://httpd.apache.org/docs /2.4/en/mod/core.html#errordocument

这篇关于如何使用.htaccess中的ErrorDocument在浏览器中保留URI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆