Why Does url-encoding the first slash after the domain break the url?

后端 未结 1 1435
情话喂你
情话喂你 2021-01-18 17:47

Salvete! I have discovered that a certain way of url encoding breaks the link. For the record %2f represents the forward slash character: /

相关标签:
1条回答
  • 2021-01-18 18:15

    The / is a reserved character. It’s not equivalent to %2f. If you need the slash without its defined meaning, you’d use the encoded form.

    See RFC 3986: "Reserved Characters":

    The purpose of reserved characters is to provide a set of delimiting characters that are distinguishable from other data within a URI. URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent. Percent- encoding a reserved character, or decoding a percent-encoded octet that corresponds to a reserved character, will change how the URI is interpreted by most applications.

    The reason why the mentionend URL still works if you don’t use the reserved char / for the second slash: their CMS simply looks for the ID part in the URL. So you can add whatever you want to the URL, e.g. the following should still work:

    http://dottech.org/95285/hey-this-URL-got-featured-at-stackoverflow
    

    (However, it seems that it still has to be / or %2f in their case.)

    If you try it with a Wikipedia article, it redirects to the front page:

    http://en.wikipedia.org/wiki%2fStack_Overflow
    
    0 讨论(0)
提交回复
热议问题