I have a primary domain - let's call it xyz.com. I also have several other secondary domains such as abc.com def.com, ghi.com, etc.. These domain all have the same content.
I am trying to do a URL redirect in IIRF that will take any of the secondary domains, and replace it with my primary xyz domain.
This is the closest I have gotten.
RewriteCond %{HTTP_HOST} ^(?!(.*)\.xyz\.com)$
RedirectRule ^/(.*)$ http://*1.xyz.com/$1
Problem #1: with this if I navigate to 123.abc.com, I am brought to .xyz.com (I am losing my sub-domain, I thought I could retrieve that with '*1').
Problem #2: even when I go to www.xyz.com, I am redirected to .xyz.com this rule should obviously ignore any xyz.com domain
I took me a week, but I got it.
##### handles 3-part domains like "xxx.yyy.com"
RewriteCond %{HTTP_HOST} ^(.*)\.(?!xyz).*\.com$
RedirectRule ^/(.*)$ http://*1.xyz.com/$1 [R=301]
and
##### handles 2-part domains like "yyy.com"
RewriteCond %{HTTP_HOST} ^(?!xyz).*\.com$
RedirectRule ^/(.*)$ http://xyz.com/$1 [R=301]