admin管理员组

文章数量:1290975

i have a url like this:

www.url.ui/?keyone=valueone&keytwo=valuetwo&ekythree=valuethree

stored in a variable:

$url = www.url.ui/?keyone=valueone&keytwo=valuetwo&keythree=valuethree

I use wp_redirect( $url ) to redirect to the url, but the problem is that after the redirect the url in the browser looks like this:

www.url.ui/?keyone=valueone&keytwo=valuetwo&keythree=valuethree

This is how a create the url above:

$param = keyone=valueone&keytwo=valuetwo&keythree=valuethree
$url .= '?' . $param;

So function itself looks like this:

function redirect(){
    $url = www.url.ui/;
    $param = keyone=valueone&keytwo=valuetwo&keythree=valuethree
    $url .= '?' . $param;
    wp_redirect( $url )
}

So the function itself works fine, but the redirected url does not look like expected. I already tried wp_sanatize_redirect() and the php function urlencode but neither of them results in what i need.

i have a url like this:

www.url.ui/?keyone=valueone&keytwo=valuetwo&ekythree=valuethree

stored in a variable:

$url = www.url.ui/?keyone=valueone&keytwo=valuetwo&keythree=valuethree

I use wp_redirect( $url ) to redirect to the url, but the problem is that after the redirect the url in the browser looks like this:

www.url.ui/?keyone=valueone&keytwo=valuetwo&keythree=valuethree

This is how a create the url above:

$param = keyone=valueone&keytwo=valuetwo&keythree=valuethree
$url .= '?' . $param;

So function itself looks like this:

function redirect(){
    $url = www.url.ui/;
    $param = keyone=valueone&keytwo=valuetwo&keythree=valuethree
    $url .= '?' . $param;
    wp_redirect( $url )
}

So the function itself works fine, but the redirected url does not look like expected. I already tried wp_sanatize_redirect() and the php function urlencode but neither of them results in what i need.

Share Improve this question edited May 29, 2015 at 5:04 s_ha_dum 65.6k13 gold badges84 silver badges174 bronze badges asked May 28, 2015 at 23:25 mieomieo 113 bronze badges 2
  • 2 Can you clarify what's wrong with the url? What you said you have and what it looks like are the same, and it looks like a valid query string. Am I missing something here? – butlerblog Commented May 29, 2015 at 4:30
  • I don't understand what the problem is. Anyway, you should pass the url through esc_url_raw() before using it for redirection. – cybmeta Commented May 29, 2015 at 4:58
Add a comment  | 

1 Answer 1

Reset to default 1

Nothing I see in Core would do that in either wp_redirect() or wp_sanitize_redirect() (which is used by wp_redirect()). However...

  1. both functions are pluggable and so could have been replaced by theme or plugin code.
  2. And wp_redirect() has the wp_redirect filter that can be used to alter the redirect location-- the part you are having trouble with. Something could be causing trouble.

I don't know how to guess at which of those two are the problem.

本文标签: wp queryWp redirect to url with ampersand string