Url 片段和 Referer 标头
想象一下,您所在的页面的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
规范规定 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.
我今天在 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.
规范基本上说你可以做任何你想做的事 - 它是一个可选的标头,我刚刚测试了 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.