Search code examples
php.htaccessurlcurlhttp-referer

Php code to know from which site does my site's url is redirected?


My client have two sites(suppose a.com and b.com) already on live and we don't have access to change there and the there is a link from where it will redirect to the new site(suppose c.com) developed my me but I have to find and save the record that from which site(a.com or b.com) it was redirected to the new c.com site. Till now I found the answer is

$_referer = $_SERVER["HTTP_REFERER"];

If you have best solution for it please answer me. Thank You!


Solution

  • the most reliable option is to add the source site to the links, as its your site.

    so on a.com a link from a may be

    www.c.com?from=a
    

    on c, the value would be in $_GET['from']

    HTTP_REFERER is unreliable as it is browser set