Archive for apache

Drupal subsites and apache conf files

We wanted 1 drupal installation (on a RedHat server, installed under /var/www/html/drupal) with a few
subsites. In the past we achieved this with many symbolic links which
gets hard to manage after a while.

Another possibility is creating CNAMES for the different subsites but
that also has its set of issues (updating dns, getting certificates…)

The solution was to create a special configuration file (in
/etc/httpd/conf.d), as follows:


<Directory /var/www/html/drupal>
   Options FollowSymLinks
   RewriteEngine on
 
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{THE_REQUEST} /subsite1/
   RewriteRule ^(.*)$ /drupal6/subsite1/?q=$1  [L]
 
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{THE_REQUEST} /subsite2/
   RewriteRule ^(.*)$ /drupal6/subsite2/?q=$1  [L]
 
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{THE_REQUEST} /
   RewriteRule ^(.*)$ /drupal/?q=$1  [L]
</Directory>
 
Alias /drupal/subsite1 "/var/www/html/drupal"
Alias /drupal/subsite2 "/var/www/html/drupal"
 

The idea is that in each of the 4 line blocks take a url which does not
correspond to a physical file or directory, and if it matches a
particular string (say ‘subsite1′) it rewrites the url in a way which is
understandable by drupal (all of this happens in a block
which refers to /var/www/html/drupal so everything is relative to
/drupal )

The Alias lines at the end of the file are needed to point urls which
start with /drupal to the correct directory.

So any new site necessitates the addition of a new 4 line block and a
new Alias line, and then restarting apache. Definitely easier than the
other solutions.

Comments off