无法在多个服务器中正确引用域

I deploy two server for production. One to hold php files and the other to hold static(css,js)files.

in config.php

$path ="https://mystaticdomain.com/";

Now to centralize the path access, I defined a variable to hold the path for the css and js files.

 <link rel="stylesheet" href="<?php echo $path;?>css/style.css">
 <script src="<?php echo $path;?>js/jquery-1.11.2.min.js"></script>

The config files are in the document root. The above header file that includes the config resides inside 'inc' folder after document root.I include the config file in the header like this:

include($_SERVER['DOCUMENT_ROOT'].'/config.php');

What happens is, instead of fetching the files from the path specified in the config, it reference to the main domain like this: www.mydomain.com.

If I hardcode the path in header itself without including the config file like this, it works!

 <link rel="stylesheet" href="https://mystaticdomain.com/css/style.css">
  <script src="https://mystaticdomain.com/js/jquery-1.11.2.min.js"></script>

Can anyone see what's the underlying problem here please?

You need to include a protocol, or the href/src attributes will be treated as relative urls.

So the $path variable should start with either http://, https:// or if you may need to use a mix of both for some reason, // which means the browser will use the current protocol to access the other server.