Redirect Regex

#908901
  • Resolved Alessandro Nuzzo
    Rank Math free

    Hello everyone, I hope you can help me. I recently performed a site migration resulting in a change to the permalink. For this reason I would need to perform a mass redirect of all the old permalinks to the new ones.

    The previous structure was made up of: sitename/category/391648808454/article-name

    (The numerical code changes with each article)

    I would like to switch everything to the classic: sitename/article-name

    I would like to redirect with Regex from Rank Math Seo.

    The problem is that I can’t figure out how to set it.

    Can you help me?

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

    We apologize for the issue you are facing with setting up your redirects after the site migration. To achieve the mass redirect from your old permalink structure sitename/category/391648808454/article-name to the new structure sitename/article-name, you can use the following Regex settings in Rank Math:

    Regex Source URL:

    ^category/[0-9]+/(.*)

    Destination URL:

    /$1

    Explanation:

    • The Source URL regex ^category/[0-9]+/(.*) matches any URL that starts with category/, followed by a numerical code (which can vary), and captures everything after that as $1.
    • The Destination URL simply uses /$1, which means it will redirect to the new structure without the category and numerical code.

    Once you have added these settings, make sure to click the Add Redirection button for the changes to take effect.

    Creating regex redirect for change in permalink structure

    If you have any further questions or need additional assistance, feel free to reply to this ticket, and a human agent from the Rank Math Support team will be happy to help you further!

    Sources:
    How to Redirect Posts After Changing URLs » Rank Math
    How to Use Regex Redirects in Rank Math » Rank Math

    I tried but the redirection doesn’t work. I think the problem is in the category field that wordpress can’t interpret. How can I replace it with a string that recalls a simple word?

    Hello,

    Thank you for contacting us.

    Please use the following regex redirection rule and see if it works for you:

    Source URL: category/[0-9]+/(.*)
    Redirection Type: Regex
    Destination URL: /$1

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    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 Regex’ is closed to new replies.