'How to prevent Google Chrome and IE substituting '|' in URL with %7C
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!
Solution 1:[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 |.
Solution 2:[2]
It's the way HTML encodes their URLs and it so happens that the character %7C is the encoded version of "|" so basically just use ~.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
| Solution 2 | dippas |
