-1

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!

unor
  • 92,415
  • 26
  • 211
  • 360
Richard Tinkler
  • 1,635
  • 3
  • 21
  • 41
  • 3
    And since encoding `|` as `%7C` in an HTTP URL context is totally _correct_, your complaint is what now exactly …? – CBroe Apr 01 '14 at 14:21
  • 1
    1.We're concerned that copying the URL with %7C might cause problems when placed on other sites; 2.It makes the URLs difficult to read which kind of defeats the purpose of using semantic URLs! – Richard Tinkler Apr 01 '14 at 14:33
  • 5
    1. You should be equally concerned that using an _unquoted_ `|` in your URLs might also cause problems the other way around, 2. well then don’t use non URL-safe characters in your “semantic” URLs in the first place! – CBroe Apr 01 '14 at 14:44
  • Our choices are limited. I wish we could be using '/' but that is unfortunately out of the question. Is there no solution to stopping '|' being substituted. Firefox AND Safari displays '|' correctly! – Richard Tinkler Apr 01 '14 at 14:52
  • 2
    Having `|` _un-encoded_ in an URL _is_ technically not correct. Browsers are so fault-tolerant however, that they usually apply the missing encoding for you if you have them in link URLs not encoded. What browsers make of it when they _display_ them in the address bar is a different matter (keyword [IRI](http://en.wikipedia.org/wiki/Internationalized_Resource_Identifier)) – but I don’t think you can _force_ anything here if the browser just doesn’t want to play along. – CBroe Apr 01 '14 at 16:05
  • See also (same OP): [Is '|' a recommended seperator for semantic URLs?](http://stackoverflow.com/q/22790773/1591669) – unor Apr 01 '14 at 16:07
  • 1
    Ok. Thanks for the info. guys. We'll find another separator! – Richard Tinkler Apr 01 '14 at 16:48
  • presently browsers from the Firefox and Chrome family remove | and %7C from the URL queries. They remain only when they were entered manually in the browser's address bar. – ñull Apr 20 '23 at 10:30

2 Answers2

2

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

Community
  • 1
  • 1
Floris
  • 45,857
  • 6
  • 70
  • 122
  • Thanks Floris. I've sometimes seen commas being used (www.example.com/page,sub-page1,sub-sub-page2). What are your thoughts on that? – Richard Tinkler Apr 02 '14 at 08:00
  • 1
    @richardTinkler the comma is not in the unreserved list. Even though you can get away with it. Go with what you think looks better. – Floris Apr 02 '14 at 10:46
1

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

dippas
  • 58,591
  • 15
  • 114
  • 126
DES
  • 11
  • 1