newbie question: need help with root path problem

newbie question: need help with root path problem

Post by Phil » Wed, 05 Jan 2005 09:34:05


My host refuses to give me full root path to my domain and I need that
to configure a couple of PHP scripts I want to install. Is there a
script that can determine the path for me so I don't need those *** ers?

Any help is appreciated.

P. McDonald
 
 
 

newbie question: need help with root path problem

Post by Oli Filt » Wed, 05 Jan 2005 09:59:25


I'm not entirely sure what it is that you're asking for, but check out
the $_SERVER variables in PHP.

For instance, the variable $_SERVER["DOCUMENT_ROOT"] is the root
directory of your website.

Oli

 
 
 

newbie question: need help with root path problem

Post by J.O. Ah » Wed, 05 Jan 2005 13:28:35


If you have a shell account access, then you can use pwd (if it's a unix based
server), this can be executed from a php script too.

<?PHP echo exec('pwd'); ?>


If you try to use

<?PHP echo $_SERVER['DOCUMENT_ROOT']; ?>

you will only get the path to the main server that is defined in the server
settings, so it's quite useless in most cases.

In this case you get a better result from

<?PHP echo $_SERVER['PHP_SELF'']; ?>

but you can get a path like /~username/html/myscript.php
instead of /home/username/html/myscript.php

<?PHP echo $_SERVER['PATH_TRANSLATED']; ?>

May work, shouldn't work with Apache2, and gives you the full path to the
script (~ is translated to a path).


//Aho
 
 
 

newbie question: need help with root path problem

Post by Michael Fe » Thu, 06 Jan 2005 05:35:15


.oO(J.O. Aho)


It's the document root of the virtual server and most likely what the OP
asked for ("root path to my domain").

Micha