markkanning Posted March 5, 2007 Share Posted March 5, 2007 Hey all, Before I end up with an imprint of my head on my office wall(and a really band headache), can someone tell me what the actual $_SERVER code is that will output the "domain name" root as opposed to the server root? In other words, I want to output "http://www.domain.com" instead of "/user/blah/m/q/stuff/morestuff/htdocs/". No PHP site seems to have a good answer for this. mark Link to comment https://forums.phpfreaks.com/topic/41319-getting-to-the-domain-name-with-_serverdocument_root/ Share on other sites More sharing options...
chronister Posted March 5, 2007 Share Posted March 5, 2007 Here is what I use. So all my links can be absolute without me having to type it all in everytime I use this <?php $root='http://'.$_SERVER['HTTP_HOST'].'/' ; ?> if you echo $root, it will output http://your_domain.ext/ Check out the manual for the $_SERVER reserved variables. http://us2.php.net/reserved.variables Link to comment https://forums.phpfreaks.com/topic/41319-getting-to-the-domain-name-with-_serverdocument_root/#findComment-200218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.