Jump to content

setting document_root


lewashby
Go to solution Solved by Ch0cu3r,

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
Share on other sites

  • Solution

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/');
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.