url - 浏览器会自动删除 URL 中的 # 吗?

标签 url hash

我们的前端人员需要形成一个包含哈希的 url,(即 http://blah/#some-link 。)当我们在浏览器上点击它并使用 fiddler 检查 http 流量时,我们看到 blah/之后的所有内容都被删除了,所以请求真的只是http://blah/ .我们还在我们的服务器 Eclipse 调试日志中确认了这一点。

请求被 Spring 安全重定向到正确的登录页面(因为用户尚未登录),但浏览器上的 url 现在显示: http://blah/some-link (哈希被删除)但浏览器上的 url 应该是 http://blah/log-in .

知道这是为什么吗?任何修复或解决方法?提前致谢。

最佳答案

# 之后的

URI 部分称为 fragment:

URI = scheme ":"hier-part [ "?"查询] [“#”片段]

Scheme 和 hier-part 识别文档的位置,片段帮助浏览器识别文档内部的位置。

在作为请求的一部分发送之前,客户端软件会从 URI 中剥离片段。

来自 RFC3986 :

the fragment identifier is not used in the scheme-specific
processing of a URI; instead, the fragment identifier is separated
from the rest of the URI prior to a dereference, and thus the
identifying information within the fragment itself is dereferenced
solely by the user agent, regardless of the URI scheme. Although
this separate handling is often perceived to be a loss of
information, particularly for accurate redirection of references as
resources move over time, it also serves to prevent information
providers from denying reference authors the right to refer to
information within a resource selectively.

关于url - 浏览器会自动删除 URL 中的 # 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9384373/

相关文章:

data-structures - Clojure:如何使用整数序列而不是字母序列来实现 trie 树?

perl - 在perl中组合2+ 'deep'(多维)哈希

php - 如何防止 apache 在 URL 路径中用单斜杠减少双斜杠?

.htaccess - 子域、丢失流量和 HTTPS 的动态 htaccess 处理

javascript - 从 URL 获取一个 JSON 文件并显示

ruby - 哈希未被识别

c# - 将 URI 转换为 GUID

ruby-on-rails - 通过键数组获取 ruby​​ 哈希值

regex - 使用扩展正则表达式的 Sed 反向引用

php - 如何在 PHP 中管理博客文章 slug 标题之前的类别名称?