Support » Plugin: Redirection » Redirection Loop. What is proper regex?

  • Hi Guys.

    I need to create redirection like:

    http://example.com/foo-(.*) -> http://example.com/bar/foo-$1

    Now I use: foo-(.*) -> bar/foo-$1.

    But anytime it hits match foo-test -> bar/foo-test -> hits again bar/bar/foo-test etc…

    How could I prevent this behaviour.

    For example if I will put this in htaccess:

    RedirectMatch 301 ^foo-(.*)/$ /bar/foo-$1/ it hits only once. The same goes with RewriteRule.

Viewing 1 replies (of 1 total)
  • Your regex will always find and replace foo-(.*) in bar/foo-$1, because it is there.

    What you are doing in the htaccess can be also done in the plugin. Try preceding your regex with a “beginning of string” token: ^, since after the first redirect bar/ will be at the start of the string.

    • This reply was modified 5 years, 1 month ago by CEMBTW.
    • This reply was modified 5 years, 1 month ago by CEMBTW.
Viewing 1 replies (of 1 total)
  • The topic ‘Redirection Loop. What is proper regex?’ is closed to new replies.