0

I am attempting to get the following 2 blocks of directives to work together, but for some reason the <Location> block is taking precedence over the <Files> block, regardless of what order I put them in:

SetEnvIfNoCase User-Agent "baidu" badbot
SetEnvIfNoCase User-Agent "meanpath" badbot
SetEnvIfNoCase User-Agent "seoengbot" badbot
SetEnvIfNoCase User-Agent "spinn3r" badbot
SetEnvIfNoCase User-Agent "ahrefs" badbot
SetEnvIfNoCase User-Agent "yandex" badbot
SetEnvIfNoCase User-Agent "dotbot" badbot
SetEnvIfNoCase User-Agent "webtarantula" badbot
SetEnvIfNoCase User-Agent "spiderbot" badbot
<Location />
        order allow,deny
        allow from all
        Deny from env=badbot
</Location>

<Files xmlrpc.php>
    Order Deny,Allow
    Deny from all
    ErrorDocument 403 "Denied"
    Allow from 127.0.0.1
    # should be Wordpress.com allowed
    Allow from 192.0.64.0/18
</Files>

When I remove the first block then access is correctly denied on xmlrpc.php server-wide, when it is in there it is allowed again. Is there a way to get these directives to coexist peacefully? It's Apache 2.2.29 on CentOS 6.7.

  • 1
    Here's a link to the [relevant documentation](https://httpd.apache.org/docs/2.2/sections.html). In particular the [section on merging](https://httpd.apache.org/docs/2.2/sections.html#mergin) should be useful. Once you've read that you'll be able to answer your own question. – user9517 Jun 09 '16 at 17:14
  • @Iain , actually, it doesn't help me much. It explains why I am seeing what I am seeing, in that `` is getting processed last, but I don't see how that helps me figure out how to structure things in such a way that both rules function the way they are supposed to. Any suggestions on what I am missing would be appreciated. – Michael VanDeMar Jun 09 '16 at 20:06

0 Answers0