(no commit message)
[paste/140.git] / domain-slash.rst
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
6 \r
7     ; HTTP\r
8 \r
9     httpurl        = "http://" hostport [ "/" hpath [ "?" search ]]\r
10     hpath          = hsegment *[ "/" hsegment ]\r
11 \r
12 http://tools.ietf.org/html/rfc1738#page-18\r
13 \r
14 \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
18 \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
21 \r
22 http://tools.ietf.org/html/rfc3986#section-6.2.3\r
23 \r
24 \r
25 WhatWG URL spec\r
26 ---------------\r
27 It also requires the slash after the domain name when serializing an URL:\r
28 \r
29   An absolute URL must be a scheme, followed by ":", followed by either a scheme-relative URL [...]\r
30 \r
31   [...]\r
32 \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
34 \r
35   [...]\r
36 \r
37   An absolute-path-relative URL must be "/", followed by a path-relative URL that does not start with "/".\r
38 \r
39 https://url.spec.whatwg.org/#writing\r
40 \r
41 \r
42 Conclusion\r
43 ----------\r
44 Add the slash.\r
45 \r
46 Good: http://cweiske.de/\r
47 Bad: http://cweiske.de\r