• princeofabyss

    (@princeofabyss)


    I discovered a very strange behavior of WP that is present even in a totally stock installation.

    I even set up a test site for the purpose of this question.

    So, suppose a page where there is some querystring with multiple terms separated by +, like mywordpress.com/sample-page/?param=val1+val2

    Now, suppose that this page shows results that span across multiple pages, and you go to page 2. Strangely, the link becomes wordpress.com/sample-page/page/2/?param=val1%20val2

    Basically, I discovered that /page/ isn’t even necessary for this strange rewrite/replacement. All that is needed is the /2/, or in general a /d/ where d is a decimal number, part for + to get replaced by %20.

    Even more strangely, when the param is the stock “s” used for the default searchbox, + isn’t replaced by %20.

    As I said, for the purpose of this question, I setup a totally stock WP site for you to see this in action.

    So, if you go here: /test/?s=test+page, you will see the returned results of the terms “test page” (I created 20 of them). So the results span across multiple pages.

    Now, if you click on page 2, you are moved to the URL /test/page/2/?s=test+page. This is perfectly fine up to here.

    However, if you change the param “s” to something else for the needs of another custom functionality, when you go to /page/2/ there is a rewrite that takes place. Study the following URLs in my test site. They don’t do anything specific, but you will see the redirection in action:

    /test/?param=test+page

    /test/page/2/?param=test+page

    See what is happening? The second URL when loaded replaces the + with a %20 if in Chrome, and with a whitespace char when in any other browser…

    Any idea why this is happening? Does it serve any particular functionality or is it just a well hidden bug? Strangely enough, even with the replacement taking place, all terms passed in the querystring are recognized, so it doesn’t break anything up. It just ruins uniformity of the URLs, and it’s driving me crazy…

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Joy

    (@joyously)

    Both the + and the %20 are the ways to represent a space in URLs. If it works, is it a bug?

    Thread Starter princeofabyss

    (@princeofabyss)

    You don’t get my point.

    When you use the default search option, you get a page similar to this:
    mywordpress.com/?s=term1+term2

    When in page 2 of the same search, the URL becomes:
    mywordpress.com/page/2/?s=term1+term2

    Notice that “+” is kept in the 1st and 2nd page?

    So, now suppose that you don’t use the stock “s” param, but a custom param name for the purposes of another functionality/plugin/whatever else.

    This time the 1st page’s URL will look like this:
    mywordpress.com/?param1=term1+term2

    BUT, the 2nd page will look like this:
    mywordpress.com/page/2/?param1=term1%20term2

    This time, the “+” is there only for the 1st page, and for the 2nd page it’s replaced by a “%20”

    And if you use a Redirect checker tool, you will notice specifically a 301 Redirect is taking place from mywordpress.com/page/2/?param1=term1+term2 -> mywordpress.com/page/2/?param1=term1%20term2

    Feel free to run a Recirect checker on this URL: /test/page/2/?param=test+page from the test installation of WP I installed for the purposes of this topic. And it’s a 100% stock installation, without any themes/plugins installed. Do you notice the redirect?

    And IMO just because it works, it doesn’t mean that it isn’t strange… I don’t know if it’s a bug, but at least the redirect is caused by some piece of code… What code is it? And what purposes does it serve other than to destroy the uniformity of URLs between various pages?

    I honestly don’t get it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Possible bug where + is replaced by in querystring when in pagination /page/’ is closed to new replies.