lewashby Posted October 20, 2013 Share Posted October 20, 2013 I am having trouble with one of my php programs because document_root is pointing to /var/www/ rather than the sub direcotry that the site is actually in, /var/www/project/site/ How can set $_SERVER['document_root'] = the directory of my site rather than /var/www/ which is just root folder of all my web projects, not the projects themselves. Quote Link to comment https://forums.phpfreaks.com/topic/283111-setting-document_root/ Share on other sites More sharing options...
Solution Ch0cu3r Posted October 20, 2013 Solution Share Posted October 20, 2013 You dont modify the document_root. What you can do is define a constant that points to your projects root directory, for example define('ROOT', $_SERVER['DOCUMENT_ROOT'] . '/project/site/'); Then when you need to include a file you'd prefix the file path with ROOT include ROOT. 'filename.php'; Include will then include filename.php from <document_root>/project/site/ Or another method is to dynamically modify the include_path set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] . '/project/site/'); Quote Link to comment https://forums.phpfreaks.com/topic/283111-setting-document_root/#findComment-1454610 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.