Skip to main content

Scott Blackburn's Library tagged htaccess   View Popular

13 Oct 09

Access all multisites with www. only [.htaccess] | drupal.org

  • # non empty HTTP_HOST in the request
            RewriteCond %{HTTP_HOST} !^$ [NC]  

    #here you exclude a domain from the universal rules
            RewriteCond %{HTTP_HOST} !^www\.excepteddomain\.com$ [NC]
            RewriteCond %{HTTP_HOST} !^excepteddomain\.com$ [NC]


    # the hostname does start with 'www.'
            RewriteCond %{HTTP_HOST} ^www\. [NC]
    # let's extract the hostname without 'www.' and save it to %1
            RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    # let's redirect to the extracted hostname, $1 saves the URL
            RewriteRule ^(.*)$ "http://%1/$1" [L,R=301]

    #here are the rules for the excepted domain
           RewriteCond %{HTTP_HOST} excepteddomain\.com$ [NC]
           RewriteCond %{HTTP_HOST} !^www\.excepteddomain\.com$ [NC]
           RewriteRule ^(.*)$ http://www.excepteddomain.com/$1 [L,R=301]

1 - 3 of 3
Showing 20 items per page

Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »

Join Diigo