Redirect with regex not working

#850799
  • Resolved Márcio Bettencourt
    Rank Math free

    Hi,
    I have Profile Builder PRO that handles recover pw emails.

    The link the plugins sends is something like: mydomain.com/lostpassword/?key=THEKEY&login=USERNAME

    I tried to set a regex redirect /lostpassword/(.*) to /recover-password/$1

    But that didn’t work.
    I also tried /lostpassword\/(.*) but no luck either.

    Is the correct way: lostpassword(.*) ?

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

    We apologize for the issue you are facing with the regex redirect. It seems like there might be a misunderstanding regarding how to properly set up the regex for your specific case.

    In your situation, since the URL contains query parameters (like ?key=THEKEY&login=USERNAME), regex patterns need to account for that. The regex you provided, /lostpassword/(.*), is close, but it won’t capture the query string.

    Instead, you can try using the following regex pattern:

    /lostpassword/

    And for the destination URL, you can simply use:

    /recover-password/

    This setup will redirect any request to /lostpassword/ to /recover-password/, regardless of the query parameters that follow.

    If you want to capture the entire URL including the query string, you might need to adjust your approach since regex in this context typically does not handle query strings directly. Instead, you can set up a redirect without capturing those parameters if they are not necessary for your new URL.

    If you still encounter issues, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further. Thank you for raising this concern!

    Sources:
    How to Use Regex Redirects in Rank Math » Rank Math
    How to Set Up Redirections » Rank Math

    Hi

    Sorry I think the regex partn didn’t came trough, this is what I see:
    https://i.imgur.com/Nt9iq7H.png

    Hello,

    Please try removing the forward slash at the beginning of the source URL so it should look like this:

    
    lostpassword/(.*)

    As for the destination URL, the $1 may not work as you are basically trying to redirect with query parameters. You can simply put /recover-password/ as your destination URL and the redirection will still include the query parameters.

    Hope that helps.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Redirect with regex not working’ is closed to new replies.