vynsane Posted March 1, 2007 Share Posted March 1, 2007 I have a site that can be accessed through multiple URL avenues: www.WallCrawlersWeb.com is also www.SpideyDatabase.com and Spider-man.Comics-Database.com because of folder structure and such, I can't use relative paths to links, and need to use absolute paths, but don't want to redirect to only one URL (the way I have been up until now.) Is there a way to create a variable like $BaseHref that I can populate with the URL that the visitor has in their address bar INCLUDING the one utilizing a sub-domain? I found this page on the drupal site http://drupal.org/node/6554 that might work - just don't know if it will work on the sub-domain version. Quote Link to comment https://forums.phpfreaks.com/topic/40748-solved-create-base-url-variable/ Share on other sites More sharing options...
Orio Posted March 1, 2007 Share Posted March 1, 2007 Try using $_SERVER['DOCUMENT_ROOT']. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/40748-solved-create-base-url-variable/#findComment-197273 Share on other sites More sharing options...
vynsane Posted March 1, 2007 Author Share Posted March 1, 2007 Thanks for the quick reply, but due to my server structure, that won't work - it's complicated... the entire website in question is in the folder "spider-man" in the folder "comics-database". My main URL is actually totally unrelated, www.vynsane.com - that's my document_root. basically to get to my spider-man site, you have to go to public_html/comics-database/spider-man/ so I need a more round-about way of doing it... Quote Link to comment https://forums.phpfreaks.com/topic/40748-solved-create-base-url-variable/#findComment-197285 Share on other sites More sharing options...
vynsane Posted March 2, 2007 Author Share Posted March 2, 2007 found that this works, even with a sub-domain: $baseURL = $_SERVER['HTTP_HOST']; FYI, anyone who needs to do this - you have to put the 'http://' in front of your echoed variable before it will work, like this: <?php $baseURL = $_SERVER['HTTP_HOST']; ?> <a href="http://<?php echo $baseURL ?>">Home</a> | <a href="http://<?php echo $baseURL ?>/news">News</a> | (etc.) Quote Link to comment https://forums.phpfreaks.com/topic/40748-solved-create-base-url-variable/#findComment-197539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.