title: One code on dev server, and production server - how to deal with links?
body: <p>I have a copy of a code running on the production server, and I use my local machine(s) running xampp as a dev server. I have several websites that I actively develop, so I'm forced to use <a href="http://localhost/sitename" rel="nofollow noreferrer">http://localhost/sitename</a></p>
  
  <p>All my URLs are relative to the domain, (/file.php). They work fine on the prod server, but on a local server, they all point to localhost, when I want to make them all work relative to the site folder they are in. Is there anything I could do, other than what I do now, which is this:</p>
  
  <pre><code>if($_SERVER['SERVER_NAME'] == "localhost") {
   $path_to = "http://" . $_SERVER['SERVER_NAME'] . "/folder";
   $path_to_files = $_SERVER['DOCUMENT_ROOT'] . "/folder";
  } else {
   $path_to = "http://" . $_SERVER['SERVER_NAME'];
   $path_to_files = $_SERVER['DOCUMENT_ROOT'];
  }
  </code></pre>
  
  <p>and simply putting <code>$path_to</code> before each link on the site.</p>