• Resolved Paul Hawkins

    (@xpired)


    Hi,

    I have this URL example: https://www.domain.com/index.php?comp=article&category=67

    It (and others like it) contain the strong “index.php?comp=article”.
    I wanna say for all old URLS’s that have that string in them redirect to /documents instead.

    I have this setup in the plugin as a REGEX redirect:
    SOURCE: /index.php?comp=article(.*)
    TARGET: /$1/documents/

    Would this work?

    Thank you.

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

    (@johnny5)

    You can test your expression here to see if it matches:

    https://regex101.com/

    I don’t think you want $1 in the target though. That would result in a URL like /&category=67/documents/

    Thread Starter Paul Hawkins

    (@xpired)

    Hi @johnny5,

    I checked it out and then did some tweaking. Does this look correct:

    Regex 101 Screenshot

    Seems good right?

    Thanks.

    Plugin Author John Godley

    (@johnny5)

    Sure, it looks like it will work. You can try it out on your site and see.

    Thread Starter Paul Hawkins

    (@xpired)

    Hey @johnny5,

    Whoop whoop! Really chuffed that I managed to figure it out myself.

    Thanks so much for your assistance. I really appreciate it.

    Have an awesome day ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redirect – Using regex to redirect if the source URL contains a certain string’ is closed to new replies.