1

I have a redirect setup like so:

r302 %r{(/example/.*)}i, 'http://new-domain.com/$1'

For this URL http://example.com/example it works great redirecting to http://new-domain.com/example

I would like to adapt this regex (or expression) to not redirect if the URL has more than one level of directory, such as http://example.com/admin/example

Neil Hoff
  • 2,025
  • 4
  • 29
  • 53
  • If `http://example.com/example` Then redirect to => `http://new-domain.com/example`? And if `http://example.com/admin/example` Don't redirect. Is it? – Caio Oliveira May 23 '14 at 15:49

1 Answers1

1

Basically we simply anchor the start of the string with ^. which matches at the start of a string and is zero-width:

r302 %r{^(/example/.*)}i, 'http://new-domain.com/$1'
Mike H-R
  • 7,726
  • 5
  • 43
  • 65