1

I have this code:

location ~* (/.*)?(?<!(food/sweet/dessert))/dollaritems {
  return 301 $1/breakfast/la/dollaritems;
}

This is working fine to redirect users going to any page with /dollaritems in the URL, except a request that includes food/sweet/dessert/dollaritems.

Now, I want to add another negative lookbehind, like this:

location ~* (/.*)?(?<!(food/sweet/dessert))(?<!(food/savory/bacon))/dollaritems {
  return 301 $1/breakfast/la/dollaritems;
}

The second negative lookbehind doesn't seem to be working.

I've also tried:

location ~* (/.*)?(?<!(food/sweet/dessert|food/savory/bacon))/dollaritems {
  return 301 $1/breakfast/la/dollaritems;
}

But that doesn't work either. Is my regex bad here or is not how I should be creating two negative lookbehinds?

Many thanks in advance.

0 Answers0