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

Referrer rediretion via .htaccess - Can you help?

Discussion in 'BlackHat Lounge' started by Bross, Nov 21, 2011.

  1. Bross

    Bross Senior Member

    Joined:
    Feb 6, 2010
    Messages:
    859
    Likes Received:
    355
    Hi guys,

    I need to redirect traffic to a specific page if they reach via google/bing, etc..
    Can anyone copy paste the rewrite rule here? I am having a hard time.

    Thanks + Rep guaranteed.
     
  2. tylerdale80

    tylerdale80 Registered Member

    Joined:
    Nov 28, 2008
    Messages:
    58
    Likes Received:
    10
    Check if the following code work for you. Remember to clear your browser cache before testing the htacess. It will even redirect if the referrer is google.co.uk.
    Code:
    RewriteEngine on
     
    RewriteCond %{HTTP_REFERER} ^http:\/\/([^.]+.)*?google.[a-zA-Z_]+ [NC]
    RewriteRule (.*) http://www.site-to-redirect-to.com/newpage.html [R=301,L]
    RewriteCond %{HTTP_REFERER} ^http:\/\/([^.]+.)*?bing.[a-zA-Z_]+ [NC]
    RewriteRule (.*) http://www.site-to-redirect-to.com/newpage.html [R=301,L]
     
    • Thanks Thanks x 1