Apache,may I have multiple documentRoot?

luca picture luca · Oct 11, 2011 · Viewed 8.8k times · Source

I'm building a Zend website.The project (local) has the following structure:

/app
  /controllers
  /views

  /public
   /css
   /images
   /js
   .htaccess
   index.php

Because the .htaccess and index.php files reside within th public directory,the public directory must be identifiable by apache as the website's document root and root directory.

So I should go to edit the "DocumentRoot from c:/wamp/www/ to c:/wamp/www/my-zend-app/public" inside the httpd.conf file. But if I do so I can't reach my other projects inside "c:/wamp/www/".. can I keep both the documentRoots?

EDIT I tried with uncommenting the httpd.conf line about "httpd-vhost.conf" and edited the file:

[httpd-vhost.conf]

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:\wamp\www\my-zend-app\application\public"
ServerName website.loc
ErrorLog "C:\wamp\www\my-zend-app\application\public\error.log"
CustomLog "C:\wamp\www\my-zend-app\application\access.log" common
</VirtualHost>

right after edited the windows hosts file adding:

127.0.0.1 website.loc

but it's not working.I'm running WAMPSERVER 2.1

Answer

jah picture jah · Oct 11, 2011

Add a <Directory> Directive to your <VirtualHost> directive for the new document root

<VirtualHost *:80>
    ...
    <Directory "C:/wamp/www/my-zend-app/application/public">
        Options Includes Indexes FollowSymLinks
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>