• Hello John,

    I need your help on something very basic. Maybe it can be done with a regular expression.

    We have built a website on an expired domain name and I see lots of URLs listed under the 404 tab in “Redirection” plugin. Some have a common root, like /common-root/ followed by different suffixes. How can I redirect all URLs starting with /common-root/ ?

    Same question for another type of URLs ending with .html

    Thanks in advance for your help.

    Best regards,
    Luc.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author John Godley

    (@johnny5)

    A regular expression should handle that.

    If you want to retain part of the original URL then something like:

    Source: ^/common-root/(.*)
    Target: /new-place/$1

    Otherwise:

    Source: ^/common-root/.*
    Target: /new-place/

    If you press the ? next to the regex option it will take you to a site that explains how to use regular expressions to match whatever pattern you want.

    Thread Starter RadCon

    (@radcon)

    Thank you very much, John. Yes, I found this page but my intelligence is limited and I have to compose with these limitations. I found it easier to understand what’s explained on this page: https://wpengine.com/support/regex/

    Do you confirm that if I put that, it will redirect all URLs ending with “.html” to the homepage?

    Source: ^\.html$
    Destination: /$1

    Or did I do a mistake?

    Once again, thanks a lot for your help, John.

    Best regards,
    Luc.

    Thread Starter RadCon

    (@radcon)

    If I want to redirect all URLs containing “p=” (be it at the beginning, in the middle or at the end of the URL), will it do in the source field?

    Source: ^\p=

    Plugin Author John Godley

    (@johnny5)

    No, none of those will work ??

    The ^ refers to the start of the line, and $ the end. If you have ^\.html$ then it will only match .html. If you want to match .html at the end then something like (.*)\.html$ will do it.

    If you want to match p= then something like .*p=.*.

    Note I haven’t tested those, so you may need to tweak them.

    If you want to test a regular expression you can use something like https://regex101.com/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do I redirect all URLs from the same category?’ is closed to new replies.