Refferrer URL Not Getting Passed in PHP Re-direction

Discussion in 'PHP' started by bigdealio, Aug 29, 2006.

  1. #1
    Surfer is coming from A to B. At B, there's a PHP redirect to C. Site B redirects to C, without giving C referrer information. Site C sees Refferrer field as blank. I'd like site C to see site B as a Refferrer. Thanks!
     
    bigdealio, Aug 29, 2006 IP
  2. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why not pass the referer as a parameter to site C? This assumes that site C is PHP that can recieve the parameter.

    For example: www.SiteB.com redirects to www.siteC.com?ref=www.SiteB.com

    Cryo.
     
    Cryogenius, Aug 29, 2006 IP
  3. bigdealio

    bigdealio Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    68
    #3
    I'm taling about the regular referrer field that is in Apache logs and stuff. I need that NOT to be empty. It is currently when I'm doing a redirect like described.
     
    bigdealio, Aug 29, 2006 IP
  4. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #4
    What kind of redirect are you doing? 301 or 302?
     
    Cryogenius, Aug 29, 2006 IP
  5. bigdealio

    bigdealio Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    68
    #5
    <?
    header('Location: http://www.SITEC.com');
    ?>

    That's in index.php
     
    bigdealio, Aug 29, 2006 IP
  6. Jordash

    Jordash Peon

    Messages:
    181
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This is what I've done in a similar situation and what Cryo was pointing at (I think)

    <?php
    header('location: http://www.domain.com/page.php?var='$varvalue);
    ?>

    That way you can pass information through the query string, e.g.

    on your next PHP page you can do:

    $varvalue=$_GET['varvalue'];

    hope that helps.
     
    Jordash, Aug 29, 2006 IP
  7. bigdealio

    bigdealio Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    68
    #7
    Site C is not under my control and I don't even know if it's using PHP or not. I need the standard httpd referrer field set so it will be server C's logs.


     
    bigdealio, Aug 29, 2006 IP
  8. Jordash

    Jordash Peon

    Messages:
    181
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hmm, your right i'm not sure what i'd do with that :(
     
    Jordash, Aug 29, 2006 IP
  9. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #9
    The problem is actually caused by the Browser. When it receives the redirect message from Site B, it is failing to send the correct Referer header to Site C. Different browsers may behave differently.

    You code was doing a 302 redirect. Perhaps a 301 redirect would work better for you...

    
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://www.SITEC.com');
    
    PHP:
    Let me explain: A 302 redirect is Temporary, and a 301 redirect is Permanent. Some search engines dislike the 302 temporay redirect, and so the general advice is to use a 301 permanent redirect when possible. You may also find that the 302 permanent redirect might pass along the referrer (I'm not sure).

    Cryo.
     
    Cryogenius, Aug 30, 2006 IP
  10. bigdealio

    bigdealio Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    68
    #10
    Nope. 301 doesn't pass the Referrer either.

     
    bigdealio, Aug 30, 2006 IP
  11. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Which browsers have you tried?

    I have to admit, I haven't got a clue why the referer isn't being passed. Perhaps it's just how it is defined in the HTTP standards.
     
    Cryogenius, Aug 30, 2006 IP
  12. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Instead of using headers, have you tried sending a page that 'auto submits' itself to the page you want them to end up at?

    That might do it...
     
    TwistMyArm, Aug 30, 2006 IP
  13. bigdealio

    bigdealio Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    68
    #13
    Internet Explorer and Opera.

     
    bigdealio, Aug 30, 2006 IP
  14. bigdealio

    bigdealio Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    68
    #14
    Don't understand what you mean or how I would do that. Maybe you could post an example code please?

     
    bigdealio, Aug 30, 2006 IP
  15. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #15
    From site B, return a page something like:
    
    <html>
        <body onload="document.getElementById('submitbutton').submit()">
            <form action="the_url_of_site_c">
                <input type="submit" name="submitbutton">
            </form>
        </body>
    </html>
    
    Code (markup):
     
    TwistMyArm, Aug 30, 2006 IP
    Cryogenius likes this.
  16. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Good thinking. Alternatively, use a meta refresh:

    
    <!-- Redirect to another webpage/website after a given time period (in this case 10 seconds) -->
    <meta http-equiv="refresh" content="10;url=http://www.wikipedia.org/">
    
    HTML:
    Should have the same effect as the javascript, but will work for everyone. It's customary to add a ordinary link for the user to click on if the redirect doesn't happen automatically. Both methods should result in the correct refer being passed on.

    Cryo.
     
    Cryogenius, Aug 30, 2006 IP