title: Is a slash ("/") equivalent to an encoded slash ("%2F") in the path portion of an HTTP URL
body: <p>I have a site that treats &quot;/&quot; and &quot;%2F&quot; in the path portion (not the query string) of a URL differently.  Is this a bad thing to do according to either the RFC or the real world?</p>
  <p>I ask because I keep running into little surprises with the web framework I'm using (Ruby on Rails) as well as the layers below that (Passenger, Apache, e.g., I had to enable &quot;ALLOW_ENCODED_SLASHES&quot; for Apache).  I am now leaning toward getting rid of the encoded slashes completely, but I wonder if I should be filing bug reports where I see weird behavior involving the encoded slashes.</p>
  <p>As to why I have the encoded slashes in the first place, basically I have routes such as this:</p>
  <pre><code>:controller/:foo/:bar
  </code></pre>
  <p>where :foo is something like a path that can contain slashes.  I thought the most straightforward thing to do would be to just URL escape <code>foo</code> so the slashes are ignored by the routing mechanism.  Now I am having doubts, and it's pretty clear that the frameworks don't really support this, but according to the RFC is it wrong to do it this way?</p>
  <p>Here is some information I have gathered:</p>
  <p>RFC 1738 (URLs):</p>
  <blockquote>
  <p>Usually a URL has the same interpretation when an octet is represented by a character and when it encoded. However, this is not true for reserved characters: encoding a character reserved for a particular scheme may change the semantics of a URL.</p>
  </blockquote>
  <p>RFC 2396 (URIs):</p>
  <blockquote>
  <p>These characters are called &quot;reserved&quot;, since their usage within the URI component is limited to their reserved purpose. If the data for a URI component would conflict with the reserved purpose, then the conflicting data must be escaped before forming the URI.</p>
  </blockquote>
  <p>(does escaping here mean something other than encoding the reserved character?)</p>
  <p>RFC 2616 (HTTP/1.1):</p>
  <blockquote>
  <p>Characters other than those in the &quot;reserved&quot; and &quot;unsafe&quot; sets (see RFC 2396 [42]) are equivalent to their &quot;&quot;%&quot; HEX HEX&quot; encoding.</p>
  </blockquote>
  <p>There is also <a href="https://rails.lighthouseapp.com/projects/8994/tickets/144-patch-bug-in-rails-route-globbing" rel="noreferrer">this bug report</a> for Rails, where they seem to expect the encoded slash to behave differently:</p>
  <blockquote>
  <p>Right, I'd expect different results because they're pointing at different resources.</p>
  <p>It's looking for the literal file 'foo/bar' in the root directory. The non escaped version is looking for the file bar within directory foo.</p>
  </blockquote>
  <p>It's clear from the RFCs that raw vs. encoded is the equivalent for unreserved characters, but what is the story for reserved characters?</p>