By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,729 Members | 1,433 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,729 IT Pros & Developers. It's quick & easy.

Document root not website root

P: n/a
jpb
Could someone please help me with this.

I want to use PHP in my website; but run into a snag, the recommended
method of calling an include is:
<?php include($_SERVER["DOCUMENT_ROOT"]."/inc/css-gateway.inc"); ?>

when I try
<?php ECHO $_SERVER["DOCUMENT_ROOT"]; ?> the document root is shown as
/usr/local/apache/htdocs/

However the website root is at:
/mnt/home/www/canadian-dream.com/www

How do I redirect $_SERVER["DOCUMENT_ROOT"] to the my website root? Is
there a global variable that can be used? I do not wish to rewrite a lot
of pages if I were to change web host in the future.

from the error logs

[Sat Oct 25 06:32:51 2003] [error] PHP Warning:
main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open stream:
No such file or directory in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
[Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
'/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
(include_path='.:/usr/local/lib/php') in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
Thanks

Paul
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"jpb" <jp*@arcor.de> wrote in message
news:pa****************************@arcor.de...
Could someone please help me with this.

I want to use PHP in my website; but run into a snag, the recommended
method of calling an include is:
<?php include($_SERVER["DOCUMENT_ROOT"]."/inc/css-gateway.inc"); ?>

when I try
<?php ECHO $_SERVER["DOCUMENT_ROOT"]; ?> the document root is shown as
/usr/local/apache/htdocs/

However the website root is at:
/mnt/home/www/canadian-dream.com/www

How do I redirect $_SERVER["DOCUMENT_ROOT"] to the my website root? Is
there a global variable that can be used? I do not wish to rewrite a lot
of pages if I were to change web host in the future.

from the error logs

[Sat Oct 25 06:32:51 2003] [error] PHP Warning:
main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open stream:
No such file or directory in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
[Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
'/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
(include_path='.:/usr/local/lib/php') in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
Thanks

Paul


Have you examined the output of phpinfo();

You have two different paths noted in your log file - One in
/usr/local/apache/htdocs, and the other in /mnt/home/www/canadian-dream.com.
The "/mnt" in one file path leads me to believe you are using NFS, which if
true, is likely to be part of the problem... If you are using Apache, I know
it can serve on an NFS server, however I do know there are some issues that
one must consider when configuring the server - I can't recall what they are
but maybe that gives you a couple of things to work on... an alternative
workaround would be to create a variable that has your "include" directory
hard-coded which you use instead of using "$_SERVER[DOCUMENT_ROOT]" -
therefore whenever you move the script, you only have to change one
variable, but I don't really like that sort of idea.

Hope that gives you some ideas...
Jul 17 '05 #2

P: n/a
jpb
On Sun, 26 Oct 2003 06:11:11 +0000, Randell D. wrote:

"jpb" <jp*@arcor.de> wrote in message
news:pa****************************@arcor.de...
Could someone please help me with this.

I want to use PHP in my website; but run into a snag, the recommended
method of calling an include is:
<?php include($_SERVER["DOCUMENT_ROOT"]."/inc/css-gateway.inc"); ?>

when I try
<?php ECHO $_SERVER["DOCUMENT_ROOT"]; ?> the document root is shown as
/usr/local/apache/htdocs/

However the website root is at:
/mnt/home/www/canadian-dream.com/www

How do I redirect $_SERVER["DOCUMENT_ROOT"] to the my website root? Is
there a global variable that can be used? I do not wish to rewrite a lot
of pages if I were to change web host in the future.

from the error logs

[Sat Oct 25 06:32:51 2003] [error] PHP Warning:
main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open
stream: No such file or directory in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
[Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
'/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
(include_path='.:/usr/local/lib/php') in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
Thanks

Paul


Have you examined the output of phpinfo();

You have two different paths noted in your log file - One in
/usr/local/apache/htdocs, and the other in
/mnt/home/www/canadian-dream.com. The "/mnt" in one file path leads me to
believe you are using NFS, which if true, is likely to be part of the
problem... If you are using Apache, I know it can serve on an NFS server,
however I do know there are some issues that one must consider when
configuring the server - I can't recall what they are but maybe that gives
you a couple of things to work on... an alternative workaround would be to
create a variable that has your "include" directory hard-coded which you
use instead of using "$_SERVER[DOCUMENT_ROOT]" - therefore whenever you
move the script, you only have to change one variable, but I don't really
like that sort of idea.

Hope that gives you some ideas...

I have a work around, not very elligent but works like a Lada

conf.php

<?php
//CONTENT OF THE FILE
$mydocumentroot=$_SERVER["DOCUMENT_ROOT"];

if($mydocumentroot!="/home/jpb/public_html/www")
{
$mydocumentroot="/mnt/home/www/canadian-dream.com/www";
}
//END OF THE INCLUDED FILE
?>
on webpage <?php include("../../../etc-etc-/inc-php": ?>
then use <?php include($mydocumentroot."bla.inc") ?>

Paul
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.