I have a set of urls :
/products
/categories
/customers
Now say a customers is named john, and I want to help john to reac
You're trying to use a negated character class the wrong way. A negated character class says 'do not match the contained characters'. What you are wanting to say is 'do not match if this stuff I specified here exists'. To do that you have to a bit more creative. Probably need some negative lookbehind. I'm not 100% sure about php's regex engine but something similar to this should work.
/^\/(?
so, negative lookbehind (? saying don't match the
.+
if products
or categories
or admin
precede it. Then that is in a non-capturing group (?: ... )
.
Check out Regular Expression Advanced Syntax Reference for extra help.