Jump to content

How can I alias the virtual host document root to / ?


mesh2005

Recommended Posts

I setup a virtual host as follows:

<VirtualHost 192.168.1.1>
        ServerAdmin webmaster@localhost
        ServerName frame
        DocumentRoot /home/username/Personal/framework
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/username/Personal/framework>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined
        ServerSignature On
</VirtualHost>

 

I put a header.php in the /home/username/Personal/framework; I created a subdirectory called test and I put a script index.php inside test that has the following code:

include "/header.php";

 

It fails and I get no such file or directory although the header.php is in the root of the virtual host. It seems that the / is not mapped to /home/username/Personal/framework, how can I fix this?

Thank you

AM

PHP does not request for files over the http protocol. Instead it does it via the OS

 

You should never begin file paths with a /. Starting file paths in this way tells PHP to look for files from the root of the hard drive. Rather than your sites document root. I recommend you to use

include "./header.php";

or a better way would be

include $_SERVER['DOCUMENR_ROOT'] . "/header.php";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.