Forum Moderators: coopster
I set a constant
define('SITE_ROOT','http://localhost/x/y/...');
which I can then switch on the new server. And then do my links like this:
echo '<a href="'. SITE_ROOT . 'a/b/page.php">Page</a>';
That seems to work OK. Do other people do that?
Then within my header script I also want to check which page is calling it. So for example if I want to check if it is the homepage of the site, I'm trying to do this:
Check if
(1) 'http://' . SITE_ROOT . 'index.php'
is equal to
(2) 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']
But will (2) give me the 'www' bit as well? Is there not a quick way to get the entire URL of the page to compare it - or is there a better way to do all this stuff.
Another consideration is to develop a function to build your urls on the fly. You could add protocol, ports, etc. if you wanted.