nginx - php-fpm: access restrictions for some php pages

m.desantis nginx-forum at
Thu Jan 31 14:12:07 UTC 2013

> Re-reading that, it comes across as more abrupt than I intended. Sorry
> about that.

No problem; unfortunately my english is poor, so easily I run into
misunderstandings when I communicate in english with other people.

> If you can now tell what I meant in the previous mail, can you suggest
> any phrasing or extra information that would have made it clear on
> first reading?

An extra information which would have been useful to me is a configuration
code example, because is less prone to misunderstandings by me (due to my
comprehension skills), or maybe some link about the matter I submitted (if
known), because I couldn't find on the web any infos about the needings I
(maybe just because the solution is trivial).

Anyway, I have a doubt: in the previous reply you sent, you say

> Your very first example was almost correct. You had
> location = /some/path/phpinfo.php {
> }
> which you said was the one location which matched the request that you
> cared about.
> In *that* location, put all of the configuration that you want for
> that request.

So I think you mean something like this:

location = /some/path/phpinfo.php {
# common configurations...
# configuration for some children urls...
location ~  \/some\/path\/(.*\.php)$ {
# common configurations...

I found that a nested locations configuration works too:

location ~  ^\/some\/path\/(.*\.php)$ {
# configuration for some children urls...
location ~ \/phpinfo\.php$ {
# common configurations...

Of the two options I would prefer the last, because I avoid to write two
different configurations equal between each other, which would imply that
time I change one configuration I have to duplicate it into the other
(but above all I have a loss of logic). Do you have some considerations
maybe I miss about the difference between the two configurations?

Posted at Nginx Forum:,235769,235783#msg-235783

More information about the nginx mailing list