Passing URL parameters

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hello,

    Thank you for contacting Rank Math today.

    I would suggest that you make use of some regex expressions to check for the URLs that you want to redirect to. I can suggest that you read through this guide to help in coming up with the most appropriate expression.
    I would suggest that you make use of this tool to test the links before using them on the live site.

    I hope this info helps. Thank you.

    ​​​​​​

    Well, I have looked at that, and I have had hose in the old Redirection plugin. As technical as I am, Regex feels really obtuse to me.

    ^\/test(.*$)

    This shows in the tool it matches things like
    /test
    /test/
    /test?src=yes

    But entering that doesn’t seem to actually work. And nothing I can come up with, regardless of regex documentation, seems to pass the parameters along. And I know it’s not your responsibility, but in the references you gave I can also not come up with a matching expression.

    Rick

    Anyone else have an idea of a regex that works that passes the parameters?

    I’d certainly appreciate an option in settings or per redirect to ask for all URL parameters to be passed through…

    Rick

    Hello,

    Thank you for contacting Rank Math today and sorry for the delay on this.

    Would you mind sharing some temporary admin access to your site so that I can investigate this issue further? Please enter the data through the sensitive data section.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,
    I have updated the sensitive data as requested. Can you please check further?
    Thank you.

    So there is a redirection called grounding (exact match) and it works if you pass a parameter:

    https://www.thrivingnow.com/grounding?user=test
    redirects to

    Grounding Exercises – Regain Your Balance and Composure


    …and does not generate a 404 error.

    Another redirection, coaching, also exact match:

    https://www.thrivingnow.com/coaching?user=test
    just goes to the 404 page and doesn’t redirect.

    Not using regex with either, and it is weird to me that one works and the other does not with the same parameters.

    This site used to use the Redirection plugin, the settings now imported into RankMath.

    Thanks for your help figuring this out!

    Rick

    Hello,

    Thank you for contacting Rank Math today and sorry for the delay.

    I have made some changes to your coaching redirection and I believe that it should now meet your criteria without using the regex.

    Let me know if this is the kind of functionality that you were after. Thank you.

    ​​​​​​

    https://www.thrivingnow.com/coaching?user=test

    This still does not redirect to

    https://www.thrivingnow.com/rick/?user=test

    Also, I just get a 404 error still with this one. What I see in the change is that you added another “exact” match, same as the first. If that is what you intended to do, could you explain why two exact matches of the same word is meant to make this work in some way?

    Thanks,
    Rick

    • This reply was modified 1 month ago by  Rick Wilkes.

    Hello,

    In order to pass URL parameters, you will need to capture a group with the regex pattern, and then reuse it in the destination URL.

    For example, you can use the following Regex pattern in the Source URL field (make sure to select the Regex comparison type in the dropdown):
    test(\?.*)?$
    And use this for the Destination URL:
    http://example/test-destination$1

    The $1 part will represent the captured group (\?.*) which is a question mark followed by any characters.

    Hope that helps.

    Wow thanks!

    test/(\?.*)?$
    
    I noticed I also needed to add a second Regex match in order the:
    
    

    /test?user=rick

    and the…

    `/test/?user=rick

    to both match. Is there a single regex that would match /test and /test/ without messing things up? Or should I just plan on entering both?

    • This reply was modified 1 month ago by  Rick Wilkes.

    Hi,

    Here’s the regex pattern for that:
    test/?(\?.*)?$
    This should match all these versions:

    /test
    /test/
    /test?a=b
    /test/?a=b

    Hope that helps. If you need anything else, don’t hesitate to ask.

    Actually, yours worked great and too great, since it would also match something like:

    https://www.thrivingnow.com/my-test/

    By putting a ^ at the start of the regex, it only matches the exact, I think:

    ^test/?(\?.*)?$
    
    Look right to you? I was getting some infinite loops with things like:
    
    

    https://www.thrivingnow.com/breathing

    redirecting to

    `https://www.thrivingnow.com/anxiety-constricted-breathing/

    unless I added the ^

    Thanks so much for helping get me there!

    Rick

    Hello Rick,

    Sorry, it took a while but we are glad that it is working now.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

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

The ticket ‘Passing URL parameters’ is closed to new replies.