浏览器会自动删除URL中的#号吗? [英] do browsers remove # in URL automatically?

查看:381
本文介绍了浏览器会自动删除URL中的#号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



请求被Spring安全性重定向到正确的登录页面(因为用户尚未登录),但浏览器上的url现在显示:
http:// blah / some-link (散列被删除),但浏览器上的网址应该是< a href =http:// blah / log-in =nofollow> http:// blah / log-in 。

任何想法为什么这是?任何修复或解决方法?在之后的URI部分被称为。

code> fragment :



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



Scheme和hier-part标识文档的位置,fragment帮助浏览器识别位于本文档中。


$ b 在客户端软件作为请求的一部分发送之前,Fragment从URI中被剥离。



RFC3986



< blockquote>

片段标识符不用于特定于方案的

处理URI;相反,在取消引用之前,片段标识符与URI的其余部分分离为
,因此片段本身的

标识信息被取消引用

不管URI方案如何,仅由用户代理完成。尽管

,这种单独的处理通常被认为是损失了

信息,特别是对于准确的引用重定向,因为资源随着时间推移而移动,它也服务于阻止信息

提供者拒绝引用作者有权在资源内选择性地引用

信息。



our front end guy needs to form a url containing the hash, (i.e, http://blah/#some-link.) when we hit this on the browser and inspect the http traffic using fiddler, we saw that everything after blah/ gets removed, so the request is really just http://blah/. we also confirmed this on our server eclipse debug log.

the request gets redirected to the correct login page by Spring security(because user hasn't logged in), but the url on the browser now shows: http://blah/some-link (the hash got removed) but the url on the browser should really be http://blah/log-in.

any idea why this is? any fix or workaround? thanks in advance.

解决方案

URI part after # is called a fragment:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

Scheme and hier-part identify the location of a document, and fragment helps the browser to identify a location inside this document.

Fragment is stripped from URI by client software before it is sent as a part of request.

From 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中的#号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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