Reply to Re: use virtual hosts to develop locally but upload throws error in source file references

Your name:

Reply:


Posted by Rik on 01/19/07 13:03

Paul wrote:
> On my development computer, I have virtual named host set up, like
> www.site1.lab.
>
> When I upload those to my web site for customer review under
> mywebsite.com/clients/site1/
> it throws some of the source file references off and it does not work
> properly.
>
> My references are like:
> require_once($_SERVER['DOCUMENT_ROOT']."/utility/top.php");
>
> Obviously those will not work since $_SERVER['DOCUMENT_ROOT']
> references mywebsite.com.
>
> Is there anything I can do in apache.conf for a virtual directory
> that would make it so when I upload a site for customer review, I
> don't have to change the source references?

As long as you've really got a virtualhost set, and set the DocmentRoot for
that domain explicitly, is should have the right $_SERVER['DOCUMENT_ROOT'].

Relevant settings:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/path/to/test/docroot"
ServerName test.localhost
</VirtualHost>

server.php:
<?php
echo $_SERVER['DOCUMENT_ROOT'];
?>
Which correctly results in : /path/to/test/docroot
--
Rik Wasmus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация