Is a URL with // in the path-section valid?

See url with multiple forward slashes, does it break anything?, Are there any downsides to using double-slashes in URLs?, What does the double slash mean in URLs? and RFC 3986 – Uniform Resource Identifier (URI): Generic Syntax.

Consensus: browsers will do the request as-is, they will not alter the request. The / character is the path separator, but as path segments are defined as:

path-abempty  = *( "/" segment )
segment       = *pchar

Means the slash after http://example.com/ can directly be followed by another slash, ad infinitum. Servers might ignore it, but browsers don’t, as you have figured out.

The phrase:

If a URI does not contain an authority component, then the path cannot begin
with two slash characters (“//”).

Allows for protocol-relative URLs, but specifically states in that case no authority (server.com:80 in your example) may be present.

So: yes, it is valid, no, don’t use it.

Leave a Comment