samoht Posted September 17, 2007 Share Posted September 17, 2007 hello again, I would like to be able to use $docRoot = $_SERVER['DOCUMENT_ROOT']; to define my path fully when linking pages. for some reason this works fine on the live server, and fine on my laptop (which uses wamp and the server name is localhost) but on my work test server )that is networked) the path always shows a C:// etc Why is this ?? And can I fix-it?? Quote Link to comment https://forums.phpfreaks.com/topic/69667-why-_serverdocument_root-sometimes-works/ Share on other sites More sharing options...
freakstyle Posted September 17, 2007 Share Posted September 17, 2007 Hey there, if you are trying to use the document root for pages you will run into trouble every time. The document root refers to actual root defined in the server configuration. Using the document root is helpful for includes and file commands in php (among many other things), just not html linking. <a href="/example.php">example</a> the above code should go to your web root (meaning the folder that is available for the users to see). if this doesn't get you directly to your root, then the server may need a variable to be set. usually these are set your environment vars. ref: http://us.php.net/getenv good luck Quote Link to comment https://forums.phpfreaks.com/topic/69667-why-_serverdocument_root-sometimes-works/#findComment-350187 Share on other sites More sharing options...
samoht Posted September 18, 2007 Author Share Posted September 18, 2007 the problem is that I have some nested pages and I don't want to have "../../../" but would much rather have a variable that starts the path correctly, so if live is www.live.com/ local(my laptop) is localhost/clientname/html/ and work is workserver/Clients/clientname/html/ I could just put the variable in to work for each case. I know I can set up a variable in a switch case exactly like this, but then for each client I have to physically change the name - it would be nice to just be able to use document root or something that fills in the first part of the url no matter what machine I am on. Quote Link to comment https://forums.phpfreaks.com/topic/69667-why-_serverdocument_root-sometimes-works/#findComment-350245 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.