1 In an URL, should I append a slash to the domain?
\r
2 =================================================
\r
3 RFC 1738: Uniform Resource Locators (URL)
\r
4 -----------------------------------------
\r
5 RFC 1738 says the slash is optional::
\r
9 httpurl = "http://" hostport [ "/" hpath [ "?" search ]]
\r
10 hpath = hsegment *[ "/" hsegment ]
\r
12 http://tools.ietf.org/html/rfc1738#page-18
\r
15 RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
\r
16 -----------------------------------------------------------
\r
17 RFC 3986 talks about normalization, and it recommends adding a slash:
\r
19 In general, a URI that uses the generic syntax for authority with an
\r
20 empty path should be normalized to a path of "/".
\r
22 http://tools.ietf.org/html/rfc3986#section-6.2.3
\r
27 It also requires the slash after the domain name when serializing an URL:
\r
29 An absolute URL must be a scheme, followed by ":", followed by either a scheme-relative URL [...]
\r
33 A scheme-relative URL must be "//", optionally followed by userinfo and "@", followed by a host, optionally followed by ":" and a port, optionally followed by an absolute-path-relative URL.
\r
37 An absolute-path-relative URL must be "/", followed by a path-relative URL that does not start with "/".
\r
39 https://url.spec.whatwg.org/#writing
\r
46 Good: http://cweiske.de/
\r
47 Bad: http://cweiske.de
\r