apache – htaccess redirect 301 all to one domain – Education Career Blog

I have 3 domains:


I want to 301 redirect all to domain3.com/$1. That includes domains with www and non-www.

domain1.com -> domain3.com
www.domain1.com/$1 -> domain3.com/$1

domain2.com -> domain3.com
www.domain2.com/$1 -> domain3.com/$1

domain3.com X-> domain3.com (no redirect)
www.domain3.com/$1 -> domain3.com/$1

Many thanks


The following will 301 redirect domain1.com and domain2.com to domain3.com. Add the www if you want it for domain3.com

RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$ NC
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ NC
RewriteRule (.*) http://domain3.com/$1 R=301,L

Leave a Comment