Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell apache to LocationMatch opposite of this?

Tags:

regex

apache

I have the following in my apache conf:

  <LocationMatch "^/assets/.*$">

How can I put in a directive that is the opposite of this?

I tried <LocationMatch "!^/assets/.*$"> but it didn't work :(

like image 523
Jacob Avatar asked Dec 17 '11 15:12

Jacob


1 Answers

With Apache 2.2 (not sure about previous versions), you can use a regular expression with a negative lookahead to match all root location URL-path directories other than /assets like so:

<LocationMatch "^(?!/assets)/[^/]+">
    ...
</LocationMatch>

Note that this does not include the root URL-path / itself.

like image 151
ridgerunner Avatar answered Nov 18 '22 20:11

ridgerunner