Nginx 1.7.0: location @php

Reinis Rozitis r at
Thu Jun 5 08:31:49 UTC 2014

> I'm sorry, I did not understood nothing. Can you provide an example of how 
> to avoid repeating the php configuration through @php location?

As someone said in earlier mails you can always use include and put the 
repeating parts in seperate files.

For example put this into php.conf:

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass fastcgi;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
    include fastcgi.conf;

And then your main config will look like:

location ^~ /alpha {
    auth_basic "Restricted Access";
    auth_basic_user_file htpasswd;
    try_files $uri $uri/ /alpha/index.php?$uri&$args;
    include php.conf;

location ^~ /beta {
    try_files $uri $uri/ /beta/index.php?$uri&$args;
    include php.conf;


More information about the nginx mailing list