23

I have an orchard site and have the following problem:

If I use the URL: http://asiahotelct.com/tours/ct---chau-%C4%91oc---ha-tien-3n2%C4%91, it's okay. But when I change url the / to %2f (like so: http://asiahotelct.com/tours%2fct---chau-%C4%91oc---ha-tien-3n2%C4%91), it no longer works.

Why can / not be replaced by %2f?

unor
  • 92,415
  • 26
  • 211
  • 360
user1796655
  • 231
  • 1
  • 2
  • 3
  • 6
    `/` is a path separator. `%2f` is a character that will eventually convert into a `/`, but is **NOT** a path separator. – Marc B Nov 03 '12 at 15:34
  • possible duplicate of [%2F in URL breaks and does not reference to the .php file required](http://stackoverflow.com/questions/9206835/2f-in-url-breaks-and-does-not-reference-to-the-php-file-required) – keithhackbarth Jun 27 '13 at 16:49
  • 1
    The subtle difference between `%2F` versus `/` was the architect of all my pain while I was trying to make my curl bash script work for `gitlab.com` REST API. – daparic Sep 02 '18 at 02:41
  • Not an answer to the question, but how to get it work: Use a parameter: http://asiahotelct.com/tours?id=ct---chau-%C4%91oc---ha-tien-3n2%C4%91 will work. – Gerard Feb 19 '23 at 09:35

1 Answers1

25

Any url is a kind of complete address to some resource(file) in network. But according to the rules of how it must be actually (to work as you expect), its expected that a few characters must have some specific meaning; just like in this case: "/" means a separator that separates the individual elements of your address(url).

But in case you need such specific characters to be a part of any such element of address(url), we must encode it. List of codes

URL encoding converts characters into a format that can be transmitted over the Internet. - w3Schools

So, "/" is actually a seperator, but "%2f" becomes an ordinary character that simply represents "/" character in element of your url.

Satyendra
  • 1,635
  • 3
  • 19
  • 33