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 http://localhost/sitename
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:
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'];
}
and simply putting $path_to
before each link on the site.