301 redirect with more than one domain... in .htaccess

Posted on 2006-05-06
Last Modified: 2010-03-04
My hosted parked more than domain such as:

I have this to do 301 redirect:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.efg\.travel [NC]
RewriteRule ^(.*)$$1 [L,R=301]

But i want use this redirect for another domain which is parked to the same host.
I used this code:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.efg\.travel [NC]
RewriteRule ^(.*)$$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.abc\.com [NC]
RewriteRule ^(.*)$$1 [L,R=301]

But it does not work. Can you solve my problem for me ? Thank u very much.
Question by:bathazar
    LVL 43

    Accepted Solution

    I Your new exapmple, first rule almost always match (it does not only for HTTP_HOST set to
    RewriteCond %{HTTP_HOST} !^www\.efg\.travel [NC] # means if user entered in his browser something other than
    No wonder, the second rule never (almost) fires.

    You need to rethink Your conditions for redirecting.
    eg: redirect to www.... if no www. was typed

    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^efg\.travel [NC] # note stripped !
    RewriteRule ^(.*)$$1 [L,R=301]
    RewriteCond %{HTTP_HOST} ^abc\.com [NC]
    RewriteRule ^(.*)$$1 [L,R=301]

    Author Comment

    Yeah ! Thank u so much !

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Remote access to WAMP / WordPress 19 74
    HTTPS Redirect Problem 17 57
    ProxyPass - Problem 5 66
    htaccess file errors for 301 Redirect 4 56
    Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
    Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now