2

I can match files just fine when using this

<Files foo-bar.php>
...
</Files>

however how do you match it if the string you're matching is like this?

<Files foo-bar.php?foo=bar>
...
</Files>
IMB
  • 15,163
  • 19
  • 82
  • 140
  • You cannot do that. If you can explain why do you need that then I can try to give you proper answer. – anubhava Dec 11 '13 at 21:52

2 Answers2

4

As David points out, one way to work around this is to use mod_rewrite, but if you have Apache 2.4 or newer, you can use the If directive, which is a lot cleaner:

<Files foo-bar.php>
   <If "%{QUERY_STRING} =~ /foo=bar/">
       ...
   </If>
</Files>

Note that the argument of the directive is actually a regular expression. It's incredibly powerful.

SáT
  • 3,633
  • 2
  • 33
  • 51
  • 1
    Note: You can nest Ifs if you have Apache 2.4.26 or above. Though I'd still like to know how to match on both path and GET params in one go, as it turns out REQUEST_URI doesn't contain params. Nesting Ifs is just so ughhh. – Artem Russakovskii Dec 14 '17 at 01:58
1

This can't be done with standard Apache directives, as discussed here.

However, depending on what you're trying to accomplish, you might have some success with mod_rewrite.

Community
  • 1
  • 1
TypeIA
  • 16,916
  • 1
  • 38
  • 52