Friday, August 30, 2013

.htaccess and Drupal Multisites

I was having trouble getting htaccess to work on the Drupal multisite I was setting up.

I figured out how I am able to do this.  Due to the way Drupal serves up the multisites, it looks to the document root for htaccess.

I ended up adding my configuration to my httpd-vhost.conf.

Just create a VirtualHost for each site.

<VirtualHost *:80>
    ServerAdmin webmaster@test.com
    DocumentRoot /var/www/html
    ServerName test.com

    <Location />
        AuthUserFile /users/jsmith/.htpasswd
        AuthName "Please Enter Password"
        AuthType Basic
        Require valid-user
    </Location>

</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@test2.com
    DocumentRoot /var/www/html
    ServerName test2.com

    <Location />
        AuthUserFile /users/tsmith/.htpasswd
        AuthName "Please Enter Password"
        AuthType Basic
        Require valid-user
    </Location>

</VirtualHost>

This is how I got it to work.  If there is a better way of doing it, please post in the comments.

ShareThis