handling subdirectories location

Thiago Farina tfransosi at gmail.com
Sun Jun 7 13:34:18 UTC 2015


Hi,

I have the following in my nginx configuration:

server {
    listen       8080;
    server_name  myservername.com;
    root /data/www/myservername.com;

    location / {
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000.
    location ~ \.php$ {
        try_files $uri = 404;
        # fastcgi_pass   unix:/var/run/php5-fpm.sock;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

But how do I configure 'location' so /subdir/index.php is processed
instead of /index.php?

Basically I'm trying to put third_party apps in their /subdirs/ to
test them, but when they navigate to index.php I'm thrown back to the
root /index.html for example.

Thanks in advance,

-- 
Thiago Farina



More information about the nginx mailing list