Global variables in css style sheets
You can write your SITE_ROOT
constant into the CSS files by parsing them with PHP. Add this to .htaccess
:
AddHandler application/x-httpd-php .css
Then embed PHP into the CSS files as you would do in any .php
file.
There is no way to do this with CSS. If you want to do something like this you could make it a PHP file and use variables that way.
But couldn't you just use absolute URLs?
background-image: url(/images/myimage.jpg);
Will work on any server, is not relative, and will find the files from the root.