Need help on .htaccess redirect based on referrer only. Pay $5

Discussion in 'Apache' started by iMerickz, Nov 5, 2009.

  1. #1
    Hi guys,
    Need some help on this..
    Can I code a .htaccess redirect based on referrer only?

    Currently I have a .htaccess redirect that directs users to another website.
    But is it possible that I can redirect users when they visit from sites like google.com or others to my main site, and then redirect users to another site if they comes from sites other then google.com (for example).

    I found this .htaccess code by Googling..

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^/site.com http://anothersite.com [L,R]

    Can anyone help me on this code.. Will pay $5 for help.. PM me pls.. :)
     
    iMerickz, Nov 5, 2009 IP
  2. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_REFERER} ^http(s)?://(.*\.)?google\.com/ [NC]
    RewriteRule ^(.*) http://redirect-because-they-did-come-from-google.com/ [R,L]
    
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?google\.com/ [NC]
    RewriteRule ^(.*) http://redirect-because-they-didnt-come-from-google.com/ [R,L]
    Code (markup):
     
    chadsmith, Nov 5, 2009 IP