Mapping the Path

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Any recommendations on the best way to map paths?


works well for files in the root folder, but for files in another
folder, I need to rewrite the path to the files, and sometimes
when testing things on my personal system, they work there,
but fail when uploaded to the website. Using the root...


doesn't seem to work as I thought it would. It's like the
server maps the '/' to something unknown. There a way
to find out what '/' gets mapped to inside the require()

Any suggestions? Thanks much.

Messing with PHP 4.4.1 (Windows XP, Apache 1.3.34
(Win32)) on my system and PHP 4.3.11 (Unix-Apache
1.3.31) on the host.

Jim Carlock
Post replies to the newsgroup.  

Re: Mapping the Path

Jim Carlock wrote:
Quoted text here. Click to load it

IMO, the most convenient way to do this is to add a php_value directive to  
the httpd.conf file:

php_value include_path ".;C:/Path to includes dir"

Or when using virtual hosts:

<VirtualHost *:80>
    php_value include_path ".;C:/Path to includes dir"


Re: Mapping the Path

Janwillem Borleffs wrote:
Quoted text here. Click to load it

Forgot to mention, with this added to the httpd.conf file, you can simply  

include 'whatever.php';

From each location in and below the site's document root and whatever.php  
will be retrieved when it's either in the current working dir or in the  
defined include path (searched for in that specific order).


Re: Mapping the Path

Quoted text here. Click to load it

Happy New Year! Thanks for the comment about php_value.

I ran across the include_path item in a few pages at

And the content of that page left me puzzled as to how or where
to place that. Also, the Unix server that the site I'm deploying to
is a hosting company. IS there a way to edit the httpd.conf file
through PHP?

And I'm trying to get some other things working to find out what
modules are installed... tried...


but that particular item is failing on my local machine.
apache_get_version() works and returns the version.

Also, found the include_path in the php.ini file. So that is
probably what I'm looking for on the local Windows
system. But will that work for the remote Apache (Unix)
server when I don't know where or how to get to it ?

The other things found in the php.ini file include:

doc_root =
user_dir =

I'm thinking my problem is an Apache problem, and I need
to create a couple virtual hosts.

For the meantime I'm going to have to stick to 100% relative
addressing for all my includes rather than using virtual root

Unless there's a way to configure the doc_root variable to use
use a different root for two or more virtuals.

Again, thank you and Happy New Year to everyone.

Jim Carlock
Post replies to the newsgroup.  

Re: Mapping the Path

Jim Carlock wrote:
Quoted text here. Click to load it

Most configurations support .htaccess overrides, Just put a file called  
.htaccess (so: dot htaccess) in de root of your webfolder and put the  
php_value directive in there.

Quoted text here. Click to load it

Then, you probably installed PHP as CGI. On my system, where PHP runs as a  
module, there isn't any problem with this function.

Quoted text here. Click to load it

For this you should test the .htaccess approach mentioned before. BTW, this  
approach will also work on Windows systems.


Re: Mapping the Path

On Sat, 31 Dec 2005 21:15:34 +0000, Jim Carlock wrote:

Quoted text here. Click to load it
require ( $_SERVER['DOCUMENT_ROOT'] . "/library/include/file1.php" );

will allow you to access anything under docroot, which is probably the
only stuff you can be sure of when on a shared server.


Site Timeline