From 1622e70898b59ec25ea334980a51cb3293f66b1d Mon Sep 17 00:00:00 2001 From: Simon Seyock Date: Tue, 8 Aug 2017 14:04:04 +0200 Subject: [PATCH] Fixing redirects The redirects where broken as there where multiple csurl parameters pasted together with '?' in the given location. This was causing "too many redirects" errors. (The $_SERVER['REQUEST_URI'] variable contains the exact uri that was called, including the query_parameters) In this solution the csurl parameter gets replaced. --- proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy.php b/proxy.php index 4c3d027..60ec4a0 100644 --- a/proxy.php +++ b/proxy.php @@ -168,7 +168,7 @@ // Rewrite the `Location` header, so clients will also use the proxy for redirects. if (preg_match('/^Location:/', $response_header)) { list($header, $value) = preg_split('/: /', $response_header, 2); - $response_header = 'Location: ' . $_SERVER['REQUEST_URI'] . '?csurl=' . $value; + $response_header = 'Location: ' . preg_replace('/\?csurl=.*/', '?csurl='.urlencode($value), $_SERVER['REQUEST_URI']); } if (!preg_match('/^(Transfer-Encoding):/', $response_header)) { header($response_header, false);