Php – how to define multiple document roots in apache

apache-2.2PHPweb

I use root relative path for all the links in PHP files, like "url(/img/myimj.jpg)"

In Godaddy host server, that works fine.

But I want to run it in my local host. (Ubuntu 9, Apache 2, PHP 5)

For example, I have my site stored in var/www/siteone, another one stored in var/www/sitetwo,

and root directory is set to "var/www".

Now the problem is a href="/" is not linking to var/www/siteone, but var/www/.

Is there a way to define different document roots for different sites?

I am just beginner in web development, not sure if vitual host can do it.

Could someone explain it?

Thanks for your answers.

I need to add new vitualhost to this file /etc/apache2/sites-available/default

But I am still confusing, how to do it for localhost? The default IP and port is always 127.0.0.1:80

Best Answer

Each <VirtualHost> section can have its own DocumentRoot directive.

Related Topic