How to get the document root (public html folder)?

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


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-22-2004
D. Alvarado
 
Posts: n/a
Default How to get the document root (public html folder)?

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
Reply With Quote
  #2 (permalink)  
Old 09-22-2004
Simon Stienen
 
Posts: n/a
Default Re: How to get the document root (public html folder)?

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
Reply With Quote
  #3 (permalink)  
Old 09-22-2004
Tony Marston
 
Posts: n/a
Default Re: How to get the document root (public html folder)?


"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



Reply With Quote
  #4 (permalink)  
Old 09-22-2004
Alvaro G. Vicario
 
Posts: n/a
Default Re: How to get the document root (public html folder)?

*** 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
--
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:49 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0