SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot yeszir's Avatar
    Join Date
    Sep 2003
    Location
    Boston
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect for a certainl referrer?

    Is there any way to send all traffic coming from a certain domain through a redirect?

    For example, say my site is siteA.com. I want people who click on a link to siteA.com on siteB.com to be sent to siteC.com instead via a redirect. Is this feasible?

    Thanks!

  2. #2
    SitePoint Evangelist Andrewaclt's Avatar
    Join Date
    Dec 2003
    Location
    Raleigh, NC
    Posts
    535
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($_SERVER['HTTP_REFERER'] == "http://www.sitea.com") {
      
    header("Location: http://www.sitec.com/");

    That should do it

  3. #3
    SitePoint Zealot yeszir's Avatar
    Join Date
    Sep 2003
    Location
    Boston
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And this would go somewhere in the header of a page, I assume?

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,227
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    redirect

    It wouldn't go anywhere in the page as the HTTP request should get redirected and the page will never load. It should go in the beginning of the file.
    Note that this will not be fool-proof, as some browsers may have referer disabled.

  5. #5
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by yeszir View Post
    Is there any way to send all traffic coming from a certain domain through a redirect?

    For example, say my site is siteA.com. I want people who click on a link to siteA.com on siteB.com to be sent to siteC.com instead via a redirect. Is this feasible?

    Thanks!
    Yes, and if possible, you should handle this with mod_rewrite or mod_redirect rules in your .htaccess/httpd.conf file, rather than invoking PHP then redirecting from there.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •