1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Multiple Redirection With .htaccess

Discussion in 'General Programming Chat' started by mtnman_sierras, May 21, 2010.

  1. mtnman_sierras

    mtnman_sierras Newbie

    Joined:
    Jan 20, 2008
    Messages:
    30
    Likes Received:
    23
    Does anyone know how to script .htaccess so that it will redirect different referers to different domains?

    Here's what I have:

    RewriteEngine on
    Options +FollowSymLinks
    RewriteCond %{HTTP_REFERER} ^http://www.referer-domain1.com$ [NC]
    RewriteRule .* http://www.yahoo.com/1$ [R=301,L]

    RewriteCond %{HTTP_REFERER} ^http://www.referer-domain2.com$ [NC]
    RewriteRule .* http://www.google.com/1$ [R=301,L]

    Only one RewriteRule works. I can't get both to work for some reason.
     
  2. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    Try taking the 'L' out of the first rewrite rule so you have:
    Code:
    RewriteRule .* http://www.yahoo.com/1$ [R=301]