Web Servers on Unix and Linux - apache - incorrect document root reported under dynamic virtual hosts

This is Interesting: Free IT Magazines  
Home > Archive > Web Servers on Unix and Linux > July 2005 > apache - incorrect document root reported under dynamic virtual hosts





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author apache - incorrect document root reported under dynamic virtual hosts
weiwang168@gmail.com

2005-07-27, 5:52 pm

I just started to try the Dynamic Virtual Hosts for Apache. All is
good, but when I have a php script that relies on
$_SERVER["DOCUMENT_ROOT"] to access some include files, it failed. The
value being reported back is the top Document Root defined in the
Apache conf file, something like '/var/www', instead of the correct
value of '/var/www/domain.com/'.

Does this mean that I cannot rely on the Document Root value when the
site is managed under Dynamic Virtual Host?

Thanks.

Wei

The Doctor

2005-07-27, 5:52 pm

In article <1122486494.398507.3080@g47g2000cwa.googlegroups.com>,
<weiwang168@gmail.com> wrote:
>I just started to try the Dynamic Virtual Hosts for Apache. All is
>good, but when I have a php script that relies on
>$_SERVER["DOCUMENT_ROOT"] to access some include files, it failed. The
>value being reported back is the top Document Root defined in the
>Apache conf file, something like '/var/www', instead of the correct
>value of '/var/www/domain.com/'.
>
>Does this mean that I cannot rely on the Document Root value when the
>site is managed under Dynamic Virtual Host?
>
>Thanks.
>
>Wei
>


Try declaring your document root

For Example:

<host 10.0.0.1>
....
DocumentRoot /usr/home/user/html
....
</host>

--
Member - Liberal International
This is doctor@nl2k.ab.ca Ici doctor@nl2k.ab.ca
God Queen and country! Beware Anti-Christ rising!
Better to serve in Heaven that to Rule in Hell.
weiwang168@gmail.com

2005-07-27, 8:47 pm

Thanks. But you did not understand my question. i am using Dynamic
Virtual Host, not the normal virtual host. So what you just said does
not apply.

Mark D Smith

2005-07-28, 2:48 am


<weiwang168@gmail.com> wrote in message
news:1122510497.716153.235990@f14g2000cwb.googlegroups.com...
> Thanks. But you did not understand my question. i am using Dynamic
> Virtual Host, not the normal virtual host. So what you just said does
> not apply.
>


Hi

look up VirtualDocumentRoot at http://httpd.apache.org/

we use

VirtualDocumentRoot /home/domain/users/%2.1/%2.2/%2/web

Mark

weiwang168@gmail.com

2005-07-28, 5:52 pm

Thanks! But how do you get around it then? Like I said, my php script
relies on the $_SERVER["DOCUMENT_ROOT"] value so that it can includes
other files correctly. If under mass vhosting, Apache does not report
that document root anymore, then my script is broken. I hate to go back
and change all the include path to relative, just thinking about all
those "../../../../" is driving me nuts.

Is there any way to have Apache report the correct document root even
using mass vhosting?

Thanks again.

Wei

Jorey Bump

2005-07-29, 5:54 pm

weiwang168@gmail.com wrote in news:1122557556.927518.15080
@g49g2000cwa.googlegroups.com:

> Thanks! But how do you get around it then? Like I said, my php script
> relies on the $_SERVER["DOCUMENT_ROOT"] value so that it can includes
> other files correctly. If under mass vhosting, Apache does not report
> that document root anymore, then my script is broken. I hate to go back
> and change all the include path to relative, just thinking about all
> those "../../../../" is driving me nuts.
>
> Is there any way to have Apache report the correct document root even
> using mass vhosting?


Depending on how you've set up mass virtual hosting, maybe you can
concatenate:

$docroot = $_SERVER["DOCUMENT_ROOT"] . "/" . $_SERVER["SERVER_NAME"]

Adjust to suit your configuration.
weiwang168@gmail.com

2005-07-29, 5:54 pm

Thanks guys! i guess i cannot rely on Apache any more. i will have to
figure something out. because i also want the script to be portable.
meaning when migrated to other hosting environment that use normal
vhosting, it will still work.

thanks!

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com