Ok so I have a url like this:
http://example.com/admin/test.php?action=edit&id=2
However I need to add in a rule to redirect this to another url with a query string like this:
http://example.com/admin/login.php?redirect=test.php%3Faction%3Dedit%26id%3D2
I added a rule like this:
RewriteRule ^admin/(.*)?$ /login.php?redirect=/admin/$1?%{QUERY_STRING} [R,L]
And it works for the most part but there is one problem, the query string is not being escaped so it is thinking those are other $_GET variables. It looks like this:
http://example.com/admin/login.php?redirect=test.php%3Faction=edit&id=2
So the redirect is reading as test.php?action=edit. It is missing the id=2 because it is reading it as another $_GET variable instead of part of the $_GET['redirect'].
Is it possible to escape the %{QUERY_STRING} ? I have googled everything I can think of and cannot find an answer anywhere.
location("header: login.php? " . encodeuri(current url));to your page that does the redirect. Then if redirect parameter is sent and login is ok use header decodeuri(redirect)