• Resolved erjjio

    (@erjjio)


    Hi – I’ve set up a redirect as follows:

    Source: /?page_id=246
    Target: /find-us

    But the actual path that it ends up redirecting to is:

    /?/find-us

    I guess this problem has something to do with the ? character existing in the source URL, but I’m not sure how to fix it and haven’t been able to track down an answer in Google or the forums – I’m sure it’s probably a common one though!

    Any suggestions?

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter erjjio

    (@erjjio)

    After fiddling around trying to figure out how to get the plugin to handle the ? character, and also trying the below solution I found, which seemed encouraging but ultimately didn’t work for me either…

    https://stackoverflow.com/questions/23503623/how-to-redirect-url-containing-question-mark-to-different-domain-with-htaccess

    …in the end, I tried installing the Simple 301 Redirect plugin instead of Redirection, and it worked like a charm straight away! So I guess I’ll just use that plugin instead from now on.

    From the SO link that you provided, note that the solution was to “escape” the question mark, which is a reserved Regex character. So use “\?” rather than just the question mark.

    Back to your original data:
    Source: /?page_id=246
    Target: /find-us
    Result: /?/find-us

    I think there are two things happening there:
    1) The slash is probably being processed as a delimiter. In this case it would expect a trailing delimiter. Since it didn’t find one it’s probably just ignoring the first.
    2) With the question mark you’re asking it to match on zero or one occurrences of a slash, followed by ‘page_id=246’.

    Since the first character is being ignored that question mark might be ignored too. So in what’s now a two-group regex, the first part is being entirely ignored. The next group is the literal ‘page_id=246’. Since it’s not processing anything before that, it leaves it alone, so ‘/?’ remains untouched. The text ‘page_id=246’ gets changed to the target ‘/find-us’, with the net result you see above.

    Quick answer, I believe you can just use this: ‘\/\?page_id=246’

    FYI: Different languages handle those delimiters differently. PHP “should” not have choked on that, but might have since it’s Perl-compatible.

    I’m no regexpert, just making guesses…

    HTH

    Thread Starter erjjio

    (@erjjio)

    Hi – thanks for your suggestions, much appreciated; I had spotted that other suggestion about adding the \ character but that didn’t seem to work for me either unfortunately..

    I did give it my best shot fiddling with Redirection, and also editing the .htaccess file directly according to the various suggestions on Stack Overflow – but in the end the only thing that seemed to work for me was to use the other plugin.

    Thanks again though.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plain permalink redirecting with /?/ in path’ is closed to new replies.