[Plugin: Redirection] QueryStrings on Pass Through to Target with QueryString
-
I was having trouble doing a passthrough to a page with query string values, but that might also have additional querystring values. For example:
Type: pass through
Regex: ^/page/view/
Target: ^/target.php?action=view
Request: /page/view/?id=1
URI: /target.php?action=view?id=1I modified pass.php to correct this issue (as well as set $_REQUEST in addition to $_GET) by replacing lines 37-42:
$_SERVER['REQUEST_URI'] = $target; if (strpos ($target, '?')) { $_SERVER['QUERY_STRING'] = substr ($target, strpos ($target, '?') + 1); parse_str ($_SERVER['QUERY_STRING'], $_GET); }
with the following:
$_SERVER['REQUEST_URI'] = $target; if (strpos ($target, '?')) { $front = substr($target, 0,strpos ($target, '?') + 1); $qsa = str_replace( '?', '&', substr($target, strpos ($target, '?') + 1)); parse_str ($qsa, $_GET); parse_str ($qsa, $_REQUEST); $_SERVER['REQUEST_URI'] = $front.$qsa; $_SERVER['QUERY_STRING'] = $qsa; }
Results
$_SERVER[‘REQUEST_URI’] = “/target.php?action=view&id=1”
$_SERVER[‘QUERY_STRING’] = “action=view&id=1”;
$_GET = array ( “action”=>”view”, “id”=>”1” )
$_REQUEST = array ( “action”=>”view”, “id”=>”1” )
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘[Plugin: Redirection] QueryStrings on Pass Through to Target with QueryString’ is closed to new replies.