Jump to content

setting document_root


lewashby

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/283111-setting-document_root/
Share on other sites

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/');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.