WordPress.org

Ready to get started?Download WordPress

Forums

wordpress 2.9.2 query string question (2 posts)

  1. shiroamada
    Member
    Posted 4 years ago #

    I just find out something with wordpress

    This is the query string I build,

    http://localhost/wp/?test=1&test=2

    print_r($_GET);

    return array.

    however, when I added ?& together, like below

    http://localhost/wp/?&test=1&test=2

    wordpress will redirect to

    http://localhost/wp/?test=1&test=2

    my test array disappear, may I know why will this happen, and what is the rational behind.

    Normal PHP should have this problem, I not sure why wordpress implement this. How can remove this trick?

    Thank you so much.

  2. shiroamada
    Member
    Posted 4 years ago #

    I did some edit, no sure it is safe or not, please comment on this solution.
    wp-includes\canonical.php
    original:

    // Note that you can use the "redirect_canonical" filter to cancel a canonical redirect for whatever reason by returning FALSE
    $redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);

    if ( !$redirect_url || $redirect_url == $requested_url ) // yes, again -- in case the filter aborted the request
    return false;

    line 293 I added

    list($base_url, $query_string) = explode('?',$requested_url);
    $position = strpos($query_string, '&');
    if($redirect_url != $requested_url)
    {
    if($position == 0)
    {
    return false;
    }
    }

    After I did the edit, I able to passing with ?& together without any problem.

Topic Closed

This topic has been closed to new replies.

About this Topic