How can I set up multiple virtual hosts in httpd.conf and have each use a different .htaccess file?

10,231

Check this SF question:

Something along these lines should help:

<VirtualHost *>
    ServerName              intranet
    DocumentRoot            /var/www/default
    <Directory "/var/www/default">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Also check this post:

Share:
10,231
Rapture
Author by

Rapture

Updated on July 13, 2022

Comments

  • Rapture
    Rapture almost 2 years

    I have many virtual hosts setup in my httpd.conf all set up like this:

    NameVirtualHost 127.0.0.1
    <VirtualHost 127.0.0.1>
        ServerName localhost
        DocumentRoot "c:/wamp/wwwWP/"
    </VirtualHost>
    
    <VirtualHost 127.0.0.1>
        ServerName testing.local
        DocumentRoot "c:/wamp/wwwtesting/"
    </VirtualHost>
    
    <VirtualHost 127.0.0.1>
        ServerName images.local
        DocumentRoot "c:/wamp/wwwimages/"
    </VirtualHost>
    

    I have commented out the #DocumentRoot line from the file. Everything works fine in my setup, but I can't figure out how to use a .htaccess file on more than one of my virtual hosts at the same time. I seem to have to change this line to the site I'm currently working on each time:

    <Directory "C:/wamp/wwwimages/">
    

    It's getting a little obnoxious. How can I set up my apache to use a .htaccess file for any virtual host that has one?

    Thanks!