Ignoring a word/path with regex

Viewed 31

I've be trying to do some redirects from a blog, to another. The paths would be like this:

From: domain/blog/posts

to: diferentDomain/blog/posts

So i came with this solution:

^/blog/(.*)

The thing is, i don't want a redirect when the origin URL has this path:

domain/blog/"wp-admin"

So i wrote something like this:

^/blog/(?!wp-admin)(.*)

But is not working at all... Does somebody knows what is happening?

1 Answers

Looks like you need to escape the forward slashes, like so:

^\/blog\/(?!wp-admin)(.*)

Here's your regex in a playground which highlights the error:

https://regex101.com/r/mXs4S2/1

Related