Redirect from one slug to another

#1006095
  • Resolved Lottie
    Rank Math free

    Hi, I am removing my custom post types and switching to categories for my blog posts. I need to redirect the old slug to the new one. I tried the regex recommendation in the guide:
    Regex source url destination
    /articles-how-to/(.*) /how-to/$1

    And this doesn’t work. I tried a few other ways, like removing the (.*) and $1 and setting it to ‘contains’ but it doesn’t seem to work. I don’t have a caching plugin.
    My other redirections work (mostly auto).

    I am doing this so that the places I have linked to the articles are redirected to the correct article. The name of the post won’t change; it will just be the category slug. As the AI bot suggested, I tried but could not find the option to add a category in the plugin.

    Do you have any suggestions?

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

    I apologize for the issue you are facing with the redirection. It sounds like you’re trying to set up a regex redirection from your old custom post type slugs to the new category slugs, which is a great way to maintain your links.

    Based on your regex source URL and destination:

    • Regex Source URL: /articles-how-to/(.*)
    • Destination URL: /how-to/$1

    This setup should work if your URLs are structured correctly. However, if it’s not functioning as expected, here are a few suggestions:

    1. Check the Regex Match Type: Ensure that you have selected the Regex option in the Match Type dropdown when setting up the redirection.

    2. Verify the Source URL: Make sure that the source URL matches exactly what you have in your website’s URLs. For example, if your URLs are structured differently or if there are any typos, the regex won’t match.

    3. Test with a Simple Redirect: As a troubleshooting step, try creating a simple redirect without regex to see if that works. For example, redirect from /articles-how-to/sample-post to /how-to/sample-post directly.

    4. Use the Redirection Debugger: If you haven’t already, use the Redirection Debugger tool in Rank Math to diagnose any issues with your redirects. This can help identify if there are conflicting redirects or other problems.

    5. Check for Conflicting Redirects: Sometimes, existing redirects can conflict with new ones. Check your existing redirects to ensure there are no overlaps that could be causing issues.

    If you continue to experience difficulties, please reply to this ticket with your site URL so we can assist you further. A human agent from our support team will be able to take over and provide more tailored assistance.

    Thank you for raising this concern, and we’re here to help you resolve it!

    Sources:
    How to Redirect Posts After Changing URLs » Rank Math
    Solving Redirection Issues Using Rank Math SEO Plugin » Rank Math

    Lottie
    Rank Math free

    I think the Regex is working. I hadn’t made any changes but was testing it, and it wasn’t working. Once I made the changes to the post type and category, the regex seems to work. There were some auto-redirects made as well.

    Hello,

    It seems that you already marked this ticket as “Resolved”.

    Do you still need our assistance regarding this issue?

    Looking forward to helping you.

    Thank you.

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

You must be logged in to reply to this ticket.