How to prevent Google Chrome and IE substituting &

2019-09-23 03:39发布

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条回答
戒情不戒烟
2楼-- · 2019-09-23 04:23

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

查看更多
登录 后发表回答