Web design, programming, graphics, and pretty much anything else I care about.

Apache rewrite for subdirectory-based Drupal multisite

In a multisite setup where there is a mix of sites based on subdomains, as well as subdirectories, the rewrite can be more complicated. Use this for the subdirectory based sites:

<Directory /var/www/html/drupal_root>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} /site1/whatever/the/path/
    RewriteRule ^(.*)$  /site1/whatever/the/path/?q=$1  [L,QSA]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{THE_REQUEST} /
    RewriteRule ^(.*)$ ?q=$1  [L,QSA]

The first rule will cover the subsite and the second one will cover the base website. They are in the same container, because they have the same document root. A subdomain-based site will have its own virtual host config with a document root.