views:

20

answers:

1

I would like to add some code to my .htaccess to redirect several different domains to a single domain. I have seen code that will do this for one domain such as:

RewriteCond %{HTTP_HOST} ^www\.example\.net  
RewriteRule (.*) http://www.example.com/$1 [R=permanent,QSA,L]

But what is the best approach to have multiple domains redirected to a single domain?

+1  A: 

Only redirect if the domain is not the one you want to redirect to:

RewriteCond %{HTTP_HOST} !(^www\.example\.com$)  
RewriteRule (.*) http://www.example.com/$1 [R=permanent,QSA,L]
Piskvor