redirection regex

#711699
  • Resolved Caglar
    Rank Math free

    Hello,

    I am having trouble creating a rule with the regex method in the routing field.

    I will ask you to help when you are available.

    previously there were many urls starting with this prefix.

    The suffix is still there but the middle suffix has changed.

    for example:

    old url:

    sitename.com/directory/abc/

    new url

    sitename.com/tedarikci/abc/

    as I said above, how can I create a relevant regex rule for this?

    because there is more than one url with the same case.

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

    I’m sorry to hear that you’re facing trouble creating a regex rule in the redirection field. I’d be happy to help you with that.

    To create a regex rule for the change in the middle suffix of your URLs, you can use the following regex:

    ^directory/(.*)

    And the destination URL should be:

    /tedarikci/$1

    This will redirect all URLs that start with sitename.com/directory/ to the new URLs with sitename.com/tedarikci/.

    If you have any further questions or need additional assistance, please feel free to reach out.

    Sources:
    How to Redirect Posts After Changing URLs » Rank Math
    How to Remove a Specific Word From Your Permalinks (URLs) » Rank Math
    How to Use Regex Redirects in Rank Math » Rank Math
    How to Set Up Redirections » Rank Math

    Caglar
    Rank Math free

    hello,

    Thank you for your support.

    I need another similar regex rule.

    my website is a listings site. listings are deactivated after a certain period of time.

    I want to redirect all these inactive listings to a fixed address with regex.

    Example:

    sitename.com/ilan/xxx/

    There are many similar urls.

    all of them:

    sitename.com/ilanlar/

    I’d like to forward it to your address.

    I would be very grateful if you could help me.

    Caglar
    Rank Math free

    Can you help me with my last message?

    Hello,

    Please share an example using the following format so we can suggest the correct regex rule:

    Source URL:
    Destination URL:

    Looking forward to helping you.

    Caglar
    Rank Math free

    kobivadisi.com/ilan/xxx/
    kobivadisi.com/ilanlar/

    The url addresses you see in the first line remain live for a certain period of time. after the time is over, they become inactive.

    I want to redirect all inactive url addresses to the main url page on line 2.

    Hello,

    What do you mean by “inactive”? Are they deleted or still published? You can use this regex below but it will redirect all URLs starting with sitename.com/ilan/ whether they’re active or not.

    Source URL: ^ilan/(.*)
    Destination URL: /ilanlar/$1

    If you want to redirect only sitename.com/ilan/xxx URLs that are ‘inactive’, then you’d have to do that outside of Rank Math.

    Thank you for your patience and cooperation

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

The ticket ‘redirection regex’ is closed to new replies.