Enable Clean URLs for Multisite subdomain

Last modified: September 6, 2009 - 01:52

If you want to use Clean URLs with a subdomain using the Multisite feature, you might eventually run into the following Problem (supposing that you succeeded in pointing the subdomain to its corresponding settings.php in the corresponding /sites/subdomain.*.* folder):

  • The Clean URL test works for the main site, but not for your subdomain.

What this wants to tell you:

  1. It's probably not a server-issue, since it works for your main site. Getting your hands on httpd.conf might not be necessary.
  2. The rewrite-rule for the creation of the subdomain works well.
  3. The rewrite-rule for Clean URLs in .htaccess applies only for the main-site.
  4. The solution for this is simple:

    Change the order of those two corresponding rewrite-rules-groups in .htaccess. Let the server first handle the Clean URLs and then rewrite to your subdomain:

      # Rewrite current-style URLs of the form 'index.php?q=x'.
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
     
      # your subdomain rule
      RewriteCond %{HTTP_HOST} subdomain.domain.xxx$
      RewriteCond %{REQUEST_URI} !subdomain/
      RewriteRule ^(.*)$ subdomain/$1

    (where domain.xxx is the url of your main site)

    httpd.conf

    Always check your http.conf if at least one of your Drupal site(s) work but the others don't.

    This will affect any htaccess rules:

    Options FollowSymLinks
    AllowOverride None # this should be All to work

    Otherwise your .htaccess won't be executed.

Please would you add an example?

RhiannonAmyBuck - October 26, 2009 - 12:13

Hi

My master site url1.org has a subdomain url2.com inside it (and url1.org also points at url2 as they are the same website).

Using your directions above, is this second section correct for my multisite setup?

------------------------------------------------------------------------------------------------------
# your subdomain rule
RewriteCond %{HTTP_HOST} url2.com.url1.org$
RewriteCond %{REQUEST_URI} !url2.com/
RewriteRule ^(.*)$ url2.com/$1
------------------------------------------------------------------------------------------------------

I've changed the .htaccess, flushed the caches, run cron, but still getting the "Your system configuration does not currently support this feature." problem. It has never worked for this website since installation, although it works for other drupal 6x sites on the same dedicated server.

(I'm on 6.13 still so just about to upgrade to 6.14).

Thank you very much.

 
 

Drupal is a registered trademark of Dries Buytaert.