HTTP_REFERER not working when user comes from HTTP code 301/307

I’ve written some simple code in PHP which save slug from my 301 redirect URL so I know how many visitors come from that advertisement. However, it’s not working when user comes from 301/307.

Example: if user comes from 301 redirect url example.com/example to redirect url to example.com/example1 now in example1 page not showing referral from this link example.com/example:

Read More
$url = example.com/example;

$data = "$url";

$j=0;   

foreach (count_chars($data, 1) as $i => $val) {
   $j=$j+$val;

}

$result = substr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',$j);

echo   $result;  

Hope this makes sense.

Related posts

Leave a Reply

2 comments

  1. Thats a normal problem of Referer Tracking. You should use other methodes to track ads.

    The most used option are Get Parameters (offer.php?ref=sitexy)