Hi all,

I have multi site Drupal installation... For all sites I need to have no-www converted to www automatically.... However just for 1 site I need the opposite thing - from www to no-www.

Right now I have one rule for each domain inside my htaccess... However, I found this rule that is generic and it converts all sites from non www to www:

# non empty HTTP_HOST in the request
        RewriteCond %{HTTP_HOST} !^$ [NC]
# does not start with 'www'
        RewriteCond %{HTTP_HOST} !^www\. [NC]
# saves the value of HTTP_HOST in %1
        RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
# redirects using the saved URI (in RewriteRule) and saved hostname (in the last RewriteCond)
        RewriteRule ^(.*)$ "http://www.%1/$1" [L,R=301]
# that's it !

It works great, but it also converts my 1 site that I need the opposite: from www to no www.

I tried having separate rule for this 1 site combined with the above mentioned generic rule, but it gets into neverending loop: it goes to www and then to no www, then again to www and so forth...

Is there a solution for this? or I just need to use separate rule for each site?

Thanks,
k.

Comments

alex’s picture

How about adding

RewriteCond %{HTTP_HOST} !^yourdomain\.com$ [NC]

where yourdomain.com is the domain you need to be accessible without www

alex

Hills Web

kalashari’s picture

Thanks a lot, that worked for me :)