4
votes

I have a multisite with drupal, I created a site which at first should be accessible in multiple ways (subdomains and paths), but now I want keep just one of them; so I whould redirect all the others. Right now I have:

aaa.domain.com/
bbb.domain.com/
domain.com/aaa/
domain.com/bbb/
www.domain.com/aaa/
www.domain.com/bbb/

And I want to redirect all of them to http://www.domain.com/bbb/

I tried to write:

RewriteCond %{HTTP_HOST} ^aaa.domain.com$ [OR]<BR>
RewriteCond %{HTTP_HOST} ^bbb.domain.com$ [OR]<BR>
RewriteCond %{HTTP_HOST} ^www.domain.com\/aaa$ [OR]<BR>
RewriteRule ^/?$ "http\:\/\/www\.domain\.com\/bbb\/" [R=302,L]

I will use 302 and no 301 until it work as expected.
If I entern aaa.domain.com it works as expected, but if I enter
http://aaa.domain.com/page/1
it don't work

I have read anything I can about htaccess, but I am missing something.

Thanks

1

1 Answers

5
votes

Add the following to your .htaccess file in the root of your domain.com site.

RewriteEngine On
RewriteBase /

#if request is not on  www.domain.com
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
#and it is not for a folder starting with /bbb/
RewriteCond %{REQUEST_URI} !^/bbb/ [NC]
#redirect to www.domain.com/bbb/
RewriteRule .* http://www.domain.com/bbb/ [L,R=301]