Title: URL Encode the redirect_parameter
Last modified: July 12, 2024

---

# URL Encode the redirect_parameter

 *  Resolved [tych095](https://wordpress.org/support/users/tych095/)
 * (@tych095)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/url-encode-the-redirect_parameter/)
 * I’m trying to redirect to a URL that includes query parameters, but it seems 
   like anything after the & in the redirect URL gets stripped out. I think its 
   because the redirect URL needs to be urlencoded().
 * e.g., in simple-page-access-restriction.php:172, if we add urlencode() to the
   home_url() .$_SERVER[‘REQUEST_URI’], it preserves the parameters.
 * $redirect_url = add_query_arg( $settings[‘redirect_parameter’], urlencode(home_url().
   $_SERVER[‘REQUEST_URI’]), $redirect_url );

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Plugins and Snippets](https://wordpress.org/support/users/pluginsandsnippets/)
 * (@pluginsandsnippets)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/url-encode-the-redirect_parameter/#post-17908536)
 * Hi [@tych095](https://wordpress.org/support/users/tych095/),
 * We have tested this and it is working fine when using query parameters in the
   URL.
 * Could you please provide more details? eg. current settings and URL.
 * Also, if you could deactivate all other plugins and switch to a standard theme
   to confirm there are no conflicts.
 * Let us know please if that helps.
 * Thank you.
 *  Thread Starter [tych095](https://wordpress.org/support/users/tych095/)
 * (@tych095)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/url-encode-the-redirect_parameter/#post-17917117)
 * Hi, I setup a clean install of wordpress and configured as follows:
    - Login Redirect Type: URL
    - Login Redirect URL: /wp-login.php
    - I then set the Privacy-Policy page to be for logged in users only
    - When I try to access the URL with query parameters:
       * [http://wordpress.test/privacy-policy/?var1=1&var2=2](http://wordpress.test/privacy-policy/?var1=1&var2=2)
       * it redirects to [http://wordpress.test/wp-login.php?redirect_to=http://wordpress.test/privacy-policy/?var1=1&var2=2](http://wordpress.test/wp-login.php?redirect_to=http://wordpress.test/privacy-policy/?var1=1&var2=2)
       * which looks fine, however after logging in, the redirect takes me to [http://wordpress.test/privacy-policy/?var1=1](http://wordpress.test/privacy-policy/?var1=1)
       * Which is missing var2 query parameter
 *  Plugin Author [Plugins and Snippets](https://wordpress.org/support/users/pluginsandsnippets/)
 * (@pluginsandsnippets)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/url-encode-the-redirect_parameter/#post-17925538)
 * Hi [@tych095](https://wordpress.org/support/users/tych095/),
 * Ah, now we understand your use case and agree with your suggestion.
 * Thank you for bringing this to our attention and for providing the detailed steps
   to replicate it.
 * We have released a new version of the plugin with this fix.
 * Could you please check the latest release and confirm if it works fine now?
 * Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘URL Encode the redirect_parameter’ is closed to new replies.

 * ![](https://ps.w.org/simple-page-access-restriction/assets/icon-256x256.png?rev
   =2795099)
 * [Simple Page Access Restriction](https://wordpress.org/plugins/simple-page-access-restriction/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-page-access-restriction/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-page-access-restriction/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-page-access-restriction/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-page-access-restriction/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-page-access-restriction/reviews/)

## Tags

 * [arguments](https://wordpress.org/support/topic-tag/arguments/)
 * [parameters](https://wordpress.org/support/topic-tag/parameters/)
 * [redirect](https://wordpress.org/support/topic-tag/redirect/)
 * [redirect_to](https://wordpress.org/support/topic-tag/redirect_to/)
 * [url](https://wordpress.org/support/topic-tag/url/)

 * 3 replies
 * 2 participants
 * Last reply from: [Plugins and Snippets](https://wordpress.org/support/users/pluginsandsnippets/)
 * Last activity: [1 year, 10 months ago](https://wordpress.org/support/topic/url-encode-the-redirect_parameter/#post-17925538)
 * Status: resolved