Url 片段和 Referer 标头

发布于 2024-09-27 05:57:19 字数 201 浏览 0 评论 0原文

想象一下,您所在的页面的 URL 包含片段(# 后面的部分),然后单击链接转到另一个页面。大多数浏览器都会在 Referer 标头中将原始页面的 URL 发送到服务器。我想知道的是 URL 片段是否会包含在其中。

我在野外见过各种行为,所以这可能是特定于浏览器的。有谁知道哪些浏览器做什么? HTTP 规范对此有何规定?

Imagine you are on a page whose URL has a fragment (the part after the #), and click a link to go to another page. Most browsers will send the URL of the original page to the server in the Referer header. What I want to know is whether or not the URL fragment will be included in this or not.

I have seen various behaviors in the wild so this might be browser-specific. Does anyone know which browsers do what? And what does the HTTP spec say on this?

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

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

发布评论

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

评论(3

梦中的蝴蝶 2024-10-04 05:57:19

规范规定 Referer 不能包含片段标识符(根据 ABNF)。请参阅 RFC 2616 第 14.36 节

The spec says that Referer can't include a fragment identifier (per ABNF). See RFC 2616, Section 14.36.

巷子口的你 2024-10-04 05:57:19

我今天在 IE 中看到了同样的行为。
我正在使用 IE 11.0.9600.17801,经过检查,我发现“Referer”标头包含此片段标识符。

Referer: //abc:8080/myapp/ver/index.htm#search-basics

虽然我很确定我在同一个浏览器上断断续续地看到过这种行为。

I saw the same behavior in IE today.
I am using IE 11.0.9600.17801 and upon inspection i found out that the 'Referer' header contains this fragment identifier.

Referer: //abc:8080/myapp/ver/index.htm#search-basics

Although I am quite certain that I have seen this behavior on and off with the same browser.

〆凄凉。 2024-10-04 05:57:19

规范基本上说你可以做任何你想做的事 - 它是一个可选的标头,我刚刚测试了 webkit 忽略了该片段,firefox 和 IE 也是如此。

The spec says basicly that you can do whatever you want - it is an optional header, i just tested webkit ignores the fragment, as do firefox and IE.

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