php/apache includes

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

Threaded View
    Not sure if this is an apache configuration or a php configuration
problem, i'm hoping someone can help. I'm running a webserver on FreeBSD
consisting of apache2 and php4 among other items. I've got a site that has
an alias directive defined in httpd.conf like:

alias /include "/path/to/directory/include"

In that area i have a file header.php which contains standard information i
want displayed across my web pages. In my index file i have:

<? include "/include/header.php"; ?>

The header.php file is not being included, not sure why. Any pointers

Re: php/apache includes

Quoted text here. Click to load it

Apache aliases don't affect require()/include() in PHP script. PHP loads the
file directly from the filesystem, hence we need a filesystem path. It can
be either absolute or relative. For the latter, the path is relative to the
directory which contain the running script. So if index.php is in
/path/to/directory, you would do include("include/header.php").

Re: php/apache includes

Quoted text here. Click to load it

This means that Apache knows that /include is an alias for /path/foo

Quoted text here. Click to load it

PHP will ask your filesystem (not Apache) for /include/bar.php

Perhaps you may want to change the include_path setting.

Tim Van Wassenhove <

Site Timeline