Are slashes allowed in URL fragment or query?

Viewed 1706

My understanding of the general form of a URL is that it looks as follows:

<scheme>://<host><path>?<query>#<fragment>

Can there be any forward slashes in either the query or the fragment? More generally, are there any characters that are specifically reserved for any single part of a URL?

3 Answers

Fragment can contain any character at all.

Query can contain any character except for #, as it is treated as marker (but you can use URL-encoding to still have it there)

So, in general, there are no any reserved characters as long as there is no ambiguity.

See RFC 3987 for the most up-to-date info. Your "general form" is not exactly right

of course you can use / in both fragment and query

An example:

<a href='#vol/p'>hash example</a>

<div style='min-height:500px;'></div>
<div id='vol/p'>
    <a href='http://jsfiddle.net/echo/jsonp?weep/sho/sdf=help'>get example</a>
</div>

jsfiddle demo

Basically you can use anything that can be encoded in an URL. moreinfo

Related