Title: [Plugin: Redirection] QueryStrings on Pass Through to Target with QueryString
Last modified: August 20, 2016

---

# [Plugin: Redirection] QueryStrings on Pass Through to Target with QueryString

 *  [lukewarmmizer](https://wordpress.org/support/users/lukewarmmizer/)
 * (@lukewarmmizer)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/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=1
 * I 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” )
 * [http://wordpress.org/extend/plugins/redirection/](http://wordpress.org/extend/plugins/redirection/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [lukewarmmizer](https://wordpress.org/support/users/lukewarmmizer/)
 * (@lukewarmmizer)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-redirection-querystrings-on-pass-through-to-target-with-querystring/#post-2736278)
 * This is what I finally went with – lets me rewrite the login page for example:
 *     ```
       $_SERVER['REQUEST_URI'] = $target;
       $index = (strpos($target,'?'))? strpos($target,'?') : strlen($target);
       $front = substr($target, 0, $index);
       $qsa = str_replace( '?', '&', substr($target, strpos ($target, '?') + 1)); // append qsa
       if (strpos ($target, '?')) {
       	parse_str ($qsa, $_GET);
       	parse_str ($qsa, $_REQUEST);
       	$_SERVER['REQUEST_URI'] = $front.'?'.$qsa;
       	$_SERVER['QUERY_STRING'] = $qsa;
       }
       if (strlen($front)-strpos ($front, '.php')==4){ // ends with php, include the file
       	include ($_SERVER['DOCUMENT_ROOT'].$front);
       	exit ();
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Redirection] QueryStrings on Pass Through to Target with QueryString’
is closed to new replies.

 * ![](https://ps.w.org/redirection/assets/icon-256x256.jpg?rev=983639)
 * [Redirection](https://wordpress.org/plugins/redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redirection/reviews/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 1 participant
 * Last reply from: [lukewarmmizer](https://wordpress.org/support/users/lukewarmmizer/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-redirection-querystrings-on-pass-through-to-target-with-querystring/#post-2736278)
 * Status: not resolved