I was asked to introduce a unified self hosted URL-Shortener/Forwarder/Tracking Service for an website that earns money from affiliates. One example I found was one of the bigger german sites for bargains. (mydealz)So I had a look at their way of doing it, and I was quite surprised.From my point of view, the only sensible way to do the forwarding and tracking is using a PHP header redirect, if 301 or 302 in my eyes is mainly a question wether you want to double track double links or not.But they do the forward using a small page using javascript window.location.href. But why?Is there any advantage that I don't see? Are there any disadvantages of the PHP redirect?As far I as tested no referer are lost while using header redirect.Thanks in advance for your help.
Redirect to an affiliate using PHP or JavaScript redirect?
php;redirects;javascript;http headers;affiliate
I just found the solution myself. There is no way to modify the referer using PHP, as this is being sent by the browser. The script I posted above is basically the same script, just without Step 1, posted by @honyovk on Stackoverflow in this topic. https://stackoverflow.com/questions/6428762/hide-referrer-on-click/11249553#11249553And probably the idea is to make sure that if someone shares the link, it still sets the correct referrer to ensure that an affiliate network relying on refferer still tracks the sale/lead/click to the right account.