• Resolved harrishun

    (@harrishun)


    Hi there!

    I’m just attempting to use the Regex option to redirect a directory back to the main page of our website.
    I’m currently testing this on this URL: [website].com/dynamic-link/news-feed?post=11
    With this Regex: /dynamic-link/.*
    However it’s redirecting to: [website].com/https:/[website].com/news-feed?post=11

    Strangely, if I remove the question mark, the redirect works flawlessly.

    I found someone stating that you need to escape the question mark, but the following regex is also not working: /dynamic-link/.*\?.*
    (I have no idea if that particular expression should work, mind you)

    Apologies if this has been answered before (I couldn’t find anything while searching), but would love for someone to point me in the right direction (:

    • This topic was modified 3 years, 11 months ago by harrishun.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author John Godley

    (@johnny5)

    Your first regex doesn’t appear to have a question mark in it anyway. The second one you have is definitely not right.

    You can use https://regex101.com/ to create and test expressions.

    It sounds like maybe your target is wrong. Can you put the full details here?

    Thread Starter harrishun

    (@harrishun)

    Ah, I see the misunderstanding, I mean that if you remove the question mark from the URL, the redirect works properly. So the strange behaviour appears to stem from that character.

    I have tested using regex101.com, and both expressions find everything in “[website].com/dynamic-link/news-feed?post=11” from “/dynamic-link/” onwards, which includes that question mark between “feed” and “post”.

    The target is just the main page of the website (formatted as [website].com).

    Thread Starter harrishun

    (@harrishun)

    Never mind, this behaviour appears to occur on our website even with the redirect turned off, so I’ll need to investigate further. I think we can safely assume it’s not a result of the plugin. Thanks for your attention in any case.

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

The topic ‘Strange Results Using Regex’ is closed to new replies.