agent provocateur
agent provocateur

Reputation: 830

LocationMatch Regex Behavior

I am trying to set a bunch of url-based rules in Apache with LocationMatch and the regex seems to behave in a way I do not understand.
I tried looking up the documentation but it isnt very clear to me WRT to my issue... nor are the other question/answers around the interwebs.

Here is my Location directive and a generic example of the structure of my LocationMatch directives:

<Location />
    Header set X-Intelligence "CatchAll"
</Location>

<LocationMatch "\.(pdf)$">
    Header set X-Intelligence "pdf1"
</LocationMatch>

I have noticed some differences between the regex used here and the regex I have experience with..


I have tried many different things but here are some examples of my results:

1.

<LocationMatch "(?i)\.(pdf)$">
    Header set X-Intelligence "pdf1"
</LocationMatch>

However:

<LocationMatch "\.(pdf)$">
    Header set X-Intelligence "pdf1"
</LocationMatch>

.
2. Not similarly:

<LocationMatch "\.(docx?)$">
    Header set X-Intelligence "doc2"
</LocationMatch>

However:

<LocationMatch "\.(doc)$">
    Header set X-Intelligence "doc2"
</LocationMatch>

<LocationMatch "\.(docx)$">
    Header set X-Intelligence "doc22"
</LocationMatch>

Not sure what is going on but the behavior is totally not what I expect.
Anyone have any ideas on what I could be doing wrong or what I am not understanding?

Open to any suggestions to make this question better. Thanks.

Upvotes: 3

Views: 2063

Answers (0)

Related Questions