play_ Posted September 6, 2009 Share Posted September 6, 2009 I have apache2 setup on my local machine with virtualhosts. In my hosts file, i have this: 127.0.1.1 mysite This just allows me to just type 'mysite' in the browser, and it servers '/media/Shared/sites/www/' I have echo $_SERVER['DOCUMENT_ROOT'] at the top of my index.php script. If i type 'http://mysite' in my browser's url, everything loads fine(on include errors, etc). And shows that the root is '/media/Shared/sites/www/mysite' If however i type http://localhost/mysite, it shows the root as /media/Shared/sites/www As you can imagine, having "2 different root dirs" causes include problems. When i wanna show friends/clients something im working on, id like to link the them to http://12.345.678/mysite (which is yields same problem as http://localhost/mysite). How can I fix this? Don't let me down phpf =( Link to comment https://forums.phpfreaks.com/topic/173299-documentroot-virtualhost-problems-i-think/ Share on other sites More sharing options...
corbin Posted September 6, 2009 Share Posted September 6, 2009 Well, you basically have 3 options: -A host name. I like no-ip.com for that, and some people like dyndns if you're looking for free solutions (and everyone knows free stuff is better ). If you have a personal domain with unlimited subdomains or something, you could always go that route. -Have the other person edit his hosts file (and most people will not know how to do that) -Do everything relative to the current folder, or use absolute paths. The main problem with this would be images/css files/js files since /image.jpg would work on http://mysite/ but not the IP address or localhost (meaning you would have to either write a ob_start() callback function to process all the links, or have href="{$ROOT}/path" type crap everywhere. Link to comment https://forums.phpfreaks.com/topic/173299-documentroot-virtualhost-problems-i-think/#findComment-913487 Share on other sites More sharing options...
play_ Posted September 6, 2009 Author Share Posted September 6, 2009 is there no other way =( ? Link to comment https://forums.phpfreaks.com/topic/173299-documentroot-virtualhost-problems-i-think/#findComment-913639 Share on other sites More sharing options...
corbin Posted September 6, 2009 Share Posted September 6, 2009 Not a way I can think of. Link to comment https://forums.phpfreaks.com/topic/173299-documentroot-virtualhost-problems-i-think/#findComment-913735 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.