<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed><type>rich</type><version>1.0</version><provider_name>phorkie</provider_name><provider_url>https://p.cweiske.de/</provider_url><title>append a slash to the domain if path is empty?</title><author_name>Christian Weiske</author_name><cache_age>86400</cache_age><width>900</width><height>900</height><html>&lt;!-- embedding all files of https://p.cweiske.de/140 --&gt;
&lt;link rel="stylesheet" href="https://p.cweiske.de/css/embed.css"/&gt;
&lt;div class="phork" id="140"&gt;
    &lt;div class="phork-file"&gt;
 &lt;div class="phork-content"&gt;
  
&lt;div class="document" id="in-an-url-should-i-append-a-slash-to-the-domain"&gt;
&lt;h1 class="title"&gt;In an URL, should I append a slash to the domain?&lt;/h1&gt;

&lt;div class="section" id="rfc-1738-uniform-resource-locators-url"&gt;
&lt;h1&gt;RFC 1738: Uniform Resource Locators (URL)&lt;/h1&gt;
&lt;p&gt;RFC 1738 says the slash is optional:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
; HTTP

httpurl        = &amp;quot;http://&amp;quot; hostport [ &amp;quot;/&amp;quot; hpath [ &amp;quot;?&amp;quot; search ]]
hpath          = hsegment *[ &amp;quot;/&amp;quot; hsegment ]
&lt;/pre&gt;
&lt;p&gt;&lt;a class="reference external" href="http://tools.ietf.org/html/rfc1738#page-18"&gt;http://tools.ietf.org/html/rfc1738#page-18&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="rfc-3986-uniform-resource-identifier-uri-generic-syntax"&gt;
&lt;h1&gt;RFC 3986: Uniform Resource Identifier (URI): Generic Syntax&lt;/h1&gt;
&lt;p&gt;RFC 3986 talks about normalization, and it recommends adding a slash:&lt;/p&gt;
&lt;blockquote&gt;
In general, a URI that uses the generic syntax for authority with an
empty path should be normalized to a path of &amp;quot;/&amp;quot;.&lt;/blockquote&gt;
&lt;p&gt;&lt;a class="reference external" href="http://tools.ietf.org/html/rfc3986#section-6.2.3"&gt;http://tools.ietf.org/html/rfc3986#section-6.2.3&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="whatwg-url-spec"&gt;
&lt;h1&gt;WhatWG URL spec&lt;/h1&gt;
&lt;p&gt;It also makes the slash after the domain name optional when serializing an URL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;An absolute URL must be a scheme, followed by &amp;quot;:&amp;quot;, followed by either a scheme-relative URL [...]&lt;/p&gt;
&lt;p&gt;[...]&lt;/p&gt;
&lt;p&gt;A scheme-relative URL must be &amp;quot;//&amp;quot;, optionally followed by userinfo and &amp;quot;&amp;#64;&amp;quot;, followed by a host, optionally followed by &amp;quot;:&amp;quot; and a port, optionally followed by an absolute-path-relative URL.&lt;/p&gt;
&lt;p&gt;[...]&lt;/p&gt;
&lt;p&gt;An absolute-path-relative URL must be &amp;quot;/&amp;quot;, followed by a path-relative URL that does not start with &amp;quot;/&amp;quot;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a class="reference external" href="https://url.spec.whatwg.org/#writing"&gt;https://url.spec.whatwg.org/#writing&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;?&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://cweiske.de/"&gt;http://cweiske.de/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://cweiske.de"&gt;http://cweiske.de&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

 &lt;/div&gt;
 &lt;div class="phork-meta"&gt;
  &lt;a href="https://p.cweiske.de/140/rev-raw/0f4b7754199ec253218452a326831d0d5c15641e/README.rst" style="float: right"&gt;view raw source&lt;/a&gt;
  &lt;a href="https://p.cweiske.de/140#README.rst"&gt;README.rst&lt;/a&gt;
 &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</html></oembed>
