301 redirect after permalink change

#841535
  • Resolved QX
    Rank Math free

    Hi, I’m looking to do a 301 redirect after a permalink change where the category has been stripped out from the URL and now it’s just sitename/postname/.

    The problem is, there doesn’t seem to be a straight forward way to do this where some posts have category/subcategory/postname and others are category/subcategory/subsubcategory/postname etc.

    Can you help?

    The bot tells me to use:

    Source URL – ^category/(.*)
    Redirect URL – /(.*)

    But this just sends the links to my homepage rather than sitename/postname/

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

    I apologize for the inconvenience you are facing with the 301 redirect after changing the permalink structure. It seems like the regex pattern provided might not be capturing the correct part of the URL for redirection.

    To redirect URLs where the category has been stripped out and now it’s just sitename/postname/, you can try using a more specific regex pattern. Here is a suggestion:

    • Source URL: ^category/(.*)
    • Destination URL: /$1

    However, to ensure the correct redirection, you might need to adjust the regex pattern based on your specific permalink structure. If the provided solution doesn’t work as expected, please provide more details about your permalink structure so we can assist you further in creating an accurate regex pattern for the redirection.

    If you need further assistance or clarification, please feel free to provide more details or screenshots, and we will be happy to help.

    Thank you for reaching out with your concern.

    Sources:
    How to Redirect Posts After Changing URLs » Rank Math
    WordPress Permalink Structure & Changing Individual URLs » Rank Math

    Hello,

    Thank you for contacting us and sorry for any inconvenience that this issue might have caused.

    Kindly use the following redirection rules:

    Source URL: category/(.*)
    Match Type: Regex
    Destination URL: /$1
    Redirection Type: 301 Permanent

    Let us know how this goes. Also, let us know if you have further questions or concerns.

    Thank you.

    QX
    Rank Math free

    Hi Ike,

    I’ve tried this but it’s still redirecting to the homepage. I’m testing in incognito mode and have purged cache.

    Hello,

    Could you please confirm if you are using the actual category name in the redirects? We have asked since the word “category” does not cover all of your post’s categories.

    If you have multiple categories, then you should create the regex redirection for each of them like the example below:

    Source URL: news/(.*)
    Source URL: sports/(.*)

    You may also share the screenshot of the redirect you have created so we can check. You can upload screenshots using this tool and add the link here.

    Looking forward to helping you.

    QX
    Rank Math free

    Hi Reinelle,

    That seems to have worked but only if I input every single subcategory. Am I right in thinking there’s no workaround for this to speed things up?

    Hello,

    Unfortunately, you may need to add those regex per category as the redirects cannot determine whether the source URL is a post or a page.

    Looking forward to helping you.

    QX
    Rank Math free

    OK, thank you for your help.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘301 redirect after permalink change’ is closed to new replies.