For including php files I use
if ( !defined('ABSPATH') ) define('ABSPATH', str_replace("core/","",dirname(__FILE__) . '/'));
As my config file is kept in core I have to remove the folder it is in.
Now this works for including php files as it gives the correct file path,and it also works on the server.
But it will not work on the following line
<link rel="stylesheet" href="css/raw/style/site.css" media="screen"/>
As this needs a url instead of a file path. Also the same for images, you need a url for these also.
After searching stack overflow people have said to use the document root and all this, but document root is only ever good on the server.
Locally I use wampserver and I have many different webpages in different folders so document root is no good. Also I write all my webpages locally before uploading. The absolute path has to work locally and on the server. I can't use a fixed path either. As I have many versions of a website. Whenever I update a website I create a new folder and number it. So constantly changing a fixed path is not going to work.
Most of my webpages use relative paths because I haven't come up with a good solution to absolute paths here.
So what is the best solution for absolute path urls which work on localhost and on the server?
PS. I know there are posts on stack overflow which answer this question, but none are giving the answer I want. Most say define a local and server address, but I use multiple folders so this won't work for me.