[UPHPU] virtual PHP hosts

Wade Preston Shearer lists at anavidesign.com
Tue Nov 23 08:32:29 MST 2004

> I am developing and testing a php app on my Windows laptop and will be
> deploying onto a linux server.  I want to use absolute paths, so I 
> defined a
> virtual host with apache on my Windows machine and likewise on my linux
> machine, so with my HTML I can do eg <img src="/images/hi.png">.  
> However this is not respected by PHP... is there a way to do something 
> similar in php so that I can include "/blah.php" instead of 
> "C:/dev/app/blah.php"?

Why do you want absolute paths? Are you not running a web server?
I would never recommend using absolute paths. And, if you must, I would 
never code them directly into the path. I would also use a variable 
(such as a define) concatenated onto the beginning of the relative 

They key is that you want your site to be independent (or "relative"). 
With relative paths, you can move it anywhere and there is no 
"installation." You simple drop it into a directly and it immediately 
works. Or, if you must have a few absolute paths, you edit one config 
file with the new paths and then they are instantly updated anywhere 
they are used.

PHP and Apache also have options for setting include directories and 
other path options. These can be set in .htaccess files, php.ini, and 
Apache's httpd.conf.

Note: Please put separate topics in separate emails. Thanks!

More information about the UPHPU mailing list