title: How to implement absolute URLs on localhost and web server?
body: <p>I've typically used the following linking practice, of <a href="https://stackoverflow.com/a/904066/1779823">relative URLs with an absolute URL path</a>:</p>
  
  <pre><code>&lt;a href="/relative/path/to/document.html"&gt;
  </code></pre>
  
  <p>But I will implement <strong>absolute URLs</strong>:</p>
  
  <pre><code>&lt;a href="http://example.com/relative/path/to/document.html"&gt;
  </code></pre>
  
  <p>It's not a problem for me to change them (automated find &amp; replace in HTML documents). </p>
  
  <p>But <strong>what is the best practice</strong> to make sure that it will work <strong>on both my localhost</strong> (which supports PHP), as well as <strong>on the web</strong>? And why?</p>
  
  <p><br></p>
  
  <p>For example, here's how I do PHP includes:</p>
  
  <pre><code>&lt;?php include($_SERVER['DOCUMENT_ROOT']."/relative/path/to/document.html"); ?&gt;
  </code></pre>
  
  <p>Adopt the same approach for <code>href</code> URLs? Is a different PHP technique better? Curious to hear why.</p>