I want to fix this vulnerability, where the URL part of a PHP redirect is given by the query-string like
https://test.dev/test.php?return_page=contact.php
which will redirect to the other site contact.php.
An attacker could use this like:
https://test.dev/test.php?return_page=http://attack.hack
My idea is to strip double slashes in the function so the resulting redirect will be internal again and probably faulty:
$_GET['url']=str_replace("//","",$_GET['url']);
But maybe there is a better way to solve this with regex?