(.htaccess question) Redirect page with condition: traffic source

2 replies
Is it possible to create a redirect page that triggered by traffic source? For example:

Main site: abc.com
- If someone referred to abc.com from website xxx.com, nothing happens
- If someone referred to abc.com from website zzz.com, then they would be redirect to vvv.com

I hope this make sense. Thank you.
#condition #htaccess #page #question #redirect #source #traffic
  • Profile picture of the author Fanzi
    YES, you can use $_SERVER['HTTP_REFERER'] The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
    {{ DiscussionBoard.errors[8989666].message }}
    • Profile picture of the author RobinInTexas
      If you use $_SERVER['HTTP_REFERER'] in an .htaccess file you will generate a 500 error and break the website.

      The correct code for .htaccess is

      Code:
      RewriteEngine On
      RewriteCond %{HTTP_REFERER} ^http://whatever.com
      RewriteRule .* http://www.wherever.com [R=301,L]
      Signature

      Robin



      ...Even if you're on the right track, you'll get run over if you just set there.
      {{ DiscussionBoard.errors[8990897].message }}

Trending Topics