Put me out of my regexing misery.


Put me out of my regexing misery.

I have a Wordpress site and I'm trying to redirect anyone trying to access one directory (and anything below that directory) that is not logged in to an error page. I have domain.com/docs/ and would like for /docs/phone or /docs/tech/office or /docs/a/b/c/90-07/gumball-snake-hugger - no matter how deep - to be redirected to a login/error page.

I'm using the super great Redirection plugin to do some other basic redirections, and thought I would take advantage of the regex ability to do this seemingly simple task. I assumed a /docs/* would work but nooooooo. I've tried /docs/[a-z0-9-]* which is close but redirects in a way that Firefox tells me will never work on some of the URLs. I've tried the Wordpress forums but have found nothing helpful and no answer to my post - it seems the prevailing answer is to "Just learn regex". I've tried $(.*[\\\/]) and [^/]+$ to no avail. I've tried building one with several "easy regex builders" but they didn't work either.

Can someone please help me with a regex that will match anything that a URL could possibly be? If there is a another way for me to achieve this end I would be open to that as well.

Previous articleNext article

POPULAR CATEGORY

corporate

9450

tech

10451

entertainment

11633

research

5071

misc

12190

wellness

9129

athletics

12244