Regex Redirection Not Working – Even for Simple Country Prefix Patterns

#1029335
  • Resolved Hannah H
    Rank Math free

    Hi Rank Math team,

    I’m currently trying to set up Regex-based redirects to remove old Shopify-style country prefixes like /de-de/, /fr-fr/, etc., from my URLs and redirect users to the correct path.

    Example:
    Redirect from:
    /de-de/collections/all
    To:
    /collections/all

    I’ve added the following redirect in Rank Math:

    Source URL: ^/de-de/(.*)

    Destination URL: /$1

    ✅ Regex enabled

    301 Permanent Move

    Status: Active

    I’ve also tried an exact match like:

    Source: ^/de-de/collections/all/?$

    Destination: /collections/all

    Neither redirect works — I still get 404 pages, and the attempts do not appear in the Redirection log at all.

    Here’s what I’ve already tried:

    Verified the regex using regex101.com

    Flushed permalinks (Settings → Permalinks → Save Changes)

    Disabled caching plugins and cleared browser cache

    Confirmed that basic non-regex redirects do work

    It appears that Rank Math isn’t able to intercept these requests at all when regex is used — even for clearly matching routes. Could this be a known limitation? Or is there anything else I can do to ensure regex rules are actually triggered?

Viewing 1 replies (of 1 total)
  • Hello,

    We apologize for the issue you are facing with the regex redirection in Rank Math. It sounds like you’ve already taken several important steps to troubleshoot the problem, which is great.

    Based on your description, here are a few things to consider:

    1. Check the Regex Pattern: Your regex pattern ^/de-de/(.*) seems correct for matching URLs that start with /de-de/. However, ensure that there are no leading slashes in the source URL field when entering it in Rank Math. The correct entry should be ^de-de/(.*) without the leading slash.

    2. Test with Other Patterns: If the above doesn’t work, try simplifying your regex to see if it matches any URLs at all. For example, use ^de-de/ as the source URL and see if it captures any requests.

    3. Server Configuration: Sometimes, server configurations (like .htaccess rules) can interfere with how redirects are processed. Ensure that there are no conflicting rules in your server settings that might prevent Rank Math from handling these redirects.

    4. Debugging: Since you mentioned that the attempts do not appear in the Redirection log, it could indicate that the requests are not reaching Rank Math at all. You might want to enable debugging in WordPress to see if there are any errors being logged that could provide more insight into the issue.

    5. Testing Environment: If possible, try testing the redirects on a staging environment to rule out any conflicts with other plugins or themes.

    If you’ve tried all of these suggestions and the issue persists, please reply to this ticket with your site URL so that a human agent from our support team can take a closer look at your specific setup and assist you further.

    Thank you for raising this concern, and we hope to resolve it for you soon!

    This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.

    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 1 replies (of 1 total)

The ticket ‘Regex Redirection Not Working – Even for Simple Country Prefix Patterns’ is closed to new replies.