Search code examples
apache.htaccess

RewriteCond excluding domain


I'm struggling with my RewriteCond in .htaccess

I have to redirect 301 all my domains (domain1.com ; domain2.com ; domain3.com) to a single domain (x1x1x1.com) except 1 (domain4.com)

Do I have to use RewriteCond to exclude domain4.com or can I exclude it immediately in the RewriteRule ?

I've tried:

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{HTTP_HOST} ^domain4\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.domain4\.com [NC]

RewriteRule ^(.*)$ https://x1x1x1.com/ [R=301,L]

</IfModule>

Thx all


Solution

  • something like this...

    <IfModule mod_rewrite.c>
    
    RewriteEngine On 
    RewriteCond %{HTTP_HOST} !domain4.com [NC]
    RewriteRule ^ https://x1x1x1.com/
    
    </IfModule>