如何防止Google Chrome和IE取代'|'在URL中使用%7C [英] How to prevent Google Chrome and IE substituting '|' in URL with %7C

查看:161
本文介绍了如何防止Google Chrome和IE取代'|'在URL中使用%7C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们改编了一个旧网站来使用语义URL,并且由于多种原因,无法使用 / 作为分隔符。相反,我们使用 | 作为分隔符。




$ b

例如:

  www.example.com/page|sub-page1|sub-sub-page2 

一切都很好,只有一个小问题。 Google Chrome浏览器和IE浏览器显示的网址为:
$ b

  www.example.com/page%7Csub我们使用&#124 ; 来编码我们的 | 分隔符,但Chrome和IE仍然以%7C 替代。  

Firefox和Safari正确显示网址!

解决方案

在你的评论中我们会找到另一个分隔符。



你可能想看看这个较早的答案,它准确地描述了URL的哪个部分允许使用哪些字符。



由此可以看出,字符你可以自由使用随意是

  unreserved = ALPHA / DIGIT / - /。 /_/〜

在我看来,所有这些字符中,是唯一可以合理取代 | 的元素。


We have adapted an old website to use semantic URLs and - for a number of reasons - are unable to use a / as a seperator. Instead, we are using | as our seperator.

For example:

www.example.com/page|sub-page1|sub-sub-page2

Everything is working fine with only one small problem. Google Chrome and IE are displaying the URL as:

www.example.com/page%7Csub-page1%7Csub-sub-page2

We are using | to encode our | seperator but Chrome and IE are still substituting with %7C.

Firefox and Safari display the URL correctly!

解决方案

You mentioned in your comment "We'll find another separator".

You might want to take a look at this earlier answer which describes exactly what characters are allowed in what part of the URL.

From this, you can see that the characters you are free to use "at will" are

unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"

It seems to me that of all these characters, the ~ is the only one that could reasonably take the place of your |.

这篇关于如何防止Google Chrome和IE取代'|'在URL中使用%7C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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