Regular Expression in Apache

Hi,

I am trying to modify a <Location /> directive in Apache so that it matches:

<Location /docroot/account>

and does not match

<Location /docroot/account/login>

Anyone know how to do this using Apache regular expressions?

/jlar

Apache uses PCREs so you can use the end of line match character.

/docroot/account$

But it’s not clear from what you wrote, perhaps you wanted to match everything in that location except login. For that perhaps a more workable way would be to rewrite that login URL to another URL that accesses the same resource.

Hello again!

Yes, basically what I want to do is, if the url matches /docroot/account/ then do whatever is in the Location directive, but not if the url matches /docroot/account/login.

I don’t think <Location /docroot/account$> would work because it would match on occasions where the url is /docroot/account/login. I don’t know though, I haven’t tried it.

/jlar

Actually /docroot/account$ does work. I tested it here:

JavaScript RegExp Example: Online Regular Expression Tester

/jlar :slight_smile:

Tested with Apache - works :slight_smile: