Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP: $_SERVER["HTTP_REFERER"] question

  • 04-01-2011 10:50pm
    #1
    Closed Accounts Posts: 4,001 ✭✭✭


    Hello all

    I have a domain, let's call it domain1.com.

    If you type domain1.com into your browser it will redirect to domain2.com. The redirect is a .htaccess 301 redirect.

    Problem: $_SERVER["HTTP_REFERER"] does not pick up that the user came from domain1.com

    How can I find out that the user came from domain1.com?

    Basically I need to do X if the user came from domain1.com, and Y if he came from domain2.com.

    Any help appreciated.

    Cheers


Comments

  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭Freddio


    this is a quote from the PHP bible

    '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."


    http://php.net/manual/en/reserved.variables.server.php

    I dont know if it makes a difference if you put an index page on server A that redirects using headers instead, but its worth a try

    <?php
    header("Location: http://serverB");
    ?>


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Does it show you the page that you were at BEFORE domain1?

    That's what I'd expect it to do.

    Try setting a GET parameter on the redirect, e.g http://www.domain2.com/via=domain1


  • Closed Accounts Posts: 4,001 ✭✭✭Mr. Loverman


    Freddio wrote: »
    this is a quote from the PHP bible

    '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."


    http://php.net/manual/en/reserved.variables.server.php

    I dont know if it makes a difference if you put an index page on server A that redirects using headers instead, but its worth a try

    <?php
    header("Location: http://serverB");
    ?>

    Thanks for the advice. Same problem unfortunately...
    Liam Byrne wrote: »
    Does it show you the page that you were at BEFORE domain1?

    That's what I'd expect it to do.

    Try setting a GET parameter on the redirect, e.g http://www.domain2.com/via=domain1

    Yeah.

    If you go to domain0.com you will see a link to domain1.com. If you click on this link you will be redirected to domain2.com.

    The referer shows the page which had the link on it.

    I'm not sure what you mean by "Try setting a GET parameter on the redirect" - I don't want anyone to see via=domain1 after the domain.

    Thanks for the advice though.


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Thanks for the advice. Same problem unfortunately...



    Yeah.

    If you go to domain0.com you will see a link to domain1.com. If you click on this link you will be redirected to domain2.com.

    The referer shows the page which had the link on it.

    I'm not sure what you mean by "Try setting a GET parameter on the redirect" - I don't want anyone to see via=domain1 after the domain.

    Thanks for the advice though.
    How about pass a get variable like Liam said in the 301 redirect.

    Collect this variable and set a session var (to remember later or if you just want to log at that moment somewhere do) and then do another forward to itself again without the variable. This will all happen behind so you shouldn't see it in the browser at any stage.

    Worth a shot.


Advertisement