Jump to content

SERVER DOCUMENT ROOT question


futrose

Recommended Posts

I have been trying to learn how to build a php/mysql website using my local computer for testing.  I'm at the point now where I need to move my files over to our server so I can give an update and show how much I have done.  On my computer I have been setting up my include lines like this.

 

include $_SERVER['DOCUMENT_ROOT'] . '/includes/head.inc.php';

 

the problem is that when I move my files over to the server I want to put them in a .htpassword protected directory called dbsite until the new site is ready to go live at which point I will move the files out of that directory and put them in the root dir.

(there is currently I live site which I am replacing with this new one in the root right now, but until I'm ready I can't delete/overwrite the current one)

 

My question is, is there a way to make

$_SERVER['DOCUMENT_ROOT'] = the dbsite dir instead of the actual root dir?  Just temporarily while the site is in the testing directory on the server.  Otherwise I have to change all of my lines on my local computer from

include $_SERVER['DOCUMENT_ROOT'] . '/includes/head.inc.php';

to

include $_SERVER['DOCUMENT_ROOT'] . '/dbsite/includes/head.inc.php';

which will then cause the files on my local computer to not work correctly.

 

Am I making sense as to my dilemma?  Is there an easier/better solution?

Thanks.

Link to comment
Share on other sites

Includes are relative to the PHP file that is first called in the browser.  So assuming you have an index.php file or something in the document root that is the first file loaded, then all includes will be relative to /docroot.  If the file is in /docroot/dbsite then this should work for both cases:

 

include 'includes/head.inc.php';

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.