How to prevent Google Chrome and IE substituting '|' in URL with %7C

可紊 提交于 2019-12-13 23:03:34

问题


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!


回答1:


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 |.



来源:https://stackoverflow.com/questions/22787919/how-to-prevent-google-chrome-and-ie-substituting-in-url-with-7c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!