0

I am trying block /administrator/ and /administrator/index.php in the nGinx server.

I have success for /administrator/ only:

        location ~* /administrator/ {
            deny all;
        }

But /administrator/index.php still responding.

I tested another configs, but I still no success.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • Regular expression `location` blocks are evaluated in order, so this block must come before the `location` which processes URIs ending with `.php`. Alternatively, use `location ^~ /administrator/` instead. See [this document](http://nginx.org/en/docs/http/ngx_http_core_module.html#location) for details. – Richard Smith Apr 13 '20 at 15:55
  • I used `location ^~ /administrator/`, but when I use `allow IP;`, the browser download the index.php – The Oldman Apr 13 '20 at 16:56
  • If you want to process `.php` files within that `location` block, you will need a nested `location`, similar to [this answer](https://stackoverflow.com/questions/37902544/nginx-sucessfully-password-protects-php-files-but-then-prompts-you-to-download/37906031#37906031) except using `allow/deny` instead of `auth_basic`. – Richard Smith Apr 13 '20 at 17:45

0 Answers0