This is a discussion on How to get the document root (public html folder)? within the PHP Language forums, part of the PHP Programming Forums category; Hello, I am running PHP 4 on my Fedora Core 2 dev machine, Apache 1.31. I made a lot ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello, I am running PHP 4 on my Fedora Core 2 dev machine, Apache
1.31. I made a lot of calls to $_SERVER['DOCUMENT_ROOT']. Unfortunately, when I move my application to a Windows environment, running on an IIS web server, the variable $_SERVER['DOCUMENT_ROOT'] is no longer supported (I always get an empty string). Question: What is a cross-web server way of finding the path to the document root -- the path to the public html folder? Thanks for your help, - Dave |
|
|||
|
D. Alvarado <"D. Alvarado" <laredotornado@zipmail.com>> wrote:
> Hello, I am running PHP 4 on my Fedora Core 2 dev machine, Apache > 1.31. I made a > lot of calls to $_SERVER['DOCUMENT_ROOT']. Unfortunately, when I move > my application to a Windows environment, running on an IIS web server, > the variable $_SERVER['DOCUMENT_ROOT'] is no longer supported (I > always get an empty string). > > Question: What is a cross-web server way of finding the path to the > document root -- the path to the public html folder? > > Thanks for your help, - Dave For most scripts you could try to obtain your current working directory and remove the path given in REQUEST_URI (or maybe another one, that fits better). var_dump($_SERVER) should help you. -- Simon Stienen <http://dangerouscat.net> <http://slashlife.de> »What you do in this world is a matter of no consequence, The question is, what can you make people believe that you have done.« -- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle |
|
|||
|
"D. Alvarado" <laredotornado@zipmail.com> wrote in message news:9fe1f2ad.0409211958.6493469f@posting.google.c om... > Hello, I am running PHP 4 on my Fedora Core 2 dev machine, Apache > 1.31. I made a > lot of calls to $_SERVER['DOCUMENT_ROOT']. Unfortunately, when I move > my application to a Windows environment, running on an IIS web server, > the variable $_SERVER['DOCUMENT_ROOT'] is no longer supported (I > always get an empty string). > > Question: What is a cross-web server way of finding the path to the > document root -- the path to the public html folder? > > Thanks for your help, - Dave You must have something wrong with your server setup because I am running PHP on Windows XP and all the $_SERVER variables are there. However, I am running Apache, not IIS, so the fault must be with IIS. What shows up when you run phpinfo()? -- Tony Marston http://www.tonymarston.net |
|
|||
|
*** Tony Marston escribió/wrote (Wed, 22 Sep 2004 10:09:29 +0100):
> You must have something wrong with your server setup because I am running > PHP on Windows XP and all the $_SERVER variables are there. However, I am > running Apache, not IIS, so the fault must be with IIS. What shows up when > you run phpinfo()? I believe you need to have PHP as Apache module to get the DOCUMENT_ROOT variable. Otherwise, PHP has no way to know such details from virtual hosts. basedir() and $_SERVER['PHP_SELF'] can be a good start. -- -+ Álvaro G. Vicario - Burgos, Spain +- http://www.demogracia.com (la web de humor barnizada para la intemperie) ++ Las dudas informáticas recibidas por correo irán directas a la papelera -+ I'm not a free help desk, please don't e-mail me your questions -- |