tyler
tyler

Reputation: 424

Different redirect with GET parameter

I´m having this affiliate link (as seen below). Why does this version of the code redirects to my desired target:

header("Location: https://www.awin1.com/cread.php?s=2079804&v=10954&q=326996&r=456987");

but that version doesn´t lead to my target. Instead it leads to "onepixel.gif"

header("Location: ".$_GET["link"]);

executed as:

linktofile.com/?link=https://www.awin1.com/cread.php?s=2079804&v=10954&q=326996&r=456987

How is the awin server able to distinguish the difference?

Upvotes: 0

Views: 96

Answers (1)

Nico Haase
Nico Haase

Reputation: 12092

If you use the URL as given (linktofile.com/?link=https://www.awin1.com/cread.php?s=2079804&v=10954&q=326996&r=456987), PHP stops to parse the first parameter $_GET['link'] at the latest at the next best ampersand, so it contains at most https://www.awin1.com/cread.php. Follow the advice of RamRaider and encode the URL parameters before rendering the link pointing to your page. It should work if the link is given as linktofile.com/?link=https%3A%2F%2Fwww.awin1.com%2Fcread.php%3Fs%3D2079804%26v%3D10954%26q%3D326996%26r%3D456987

Upvotes: 1

Related Questions