Reputation: 3676
location /social {
index index.php;
try_files $uri /social/index.php;
}
When a user hits up a directory, it needs to run the local ./index.php So far, when people hit up /social/ it runs index.php When the user visits all unknown URLs, they get /social/index.php
However, when a user vists /social/subdir/ and there is a /social/subdir/index.php, it still runs /social/index.php. I need it to run /social/subdir/index.php
if I change the config to:
location /social {
index index.php;
try_files $uri $uri/index.php /social/index.php;
}
Then nginx serves up the CONTENT of social/subdir/index.php as content-type: octet/stream.
I thought index index.php would look for the paths index file.
php rendering block:
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
Upvotes: 0
Views: 844
Reputation: 42799
I think your main issue is that you didn't use http://
before 127.0.0.1:9000
, also make sure that your php uses port 9000 not a sock file, otherwise you change the fastcgi_pass
to unix socket.
Here's my simplified config.
Remove the index index.php
from the /social
block if it's the same value in the server
block.
location /social {
# index index.php; # remove if not needed
try_files $uri $uri/ /social/index.php;
}
location ~* \.php$ {
include fastcgi_params;
fastcgi_pass http://127.0.0.1:9000;
}
Upvotes: 1
Reputation: 3406
First remove the index.php from the try_files directive so it will look like this
location /social {
index index.php;
try_files $uri $uri/ /social/index.php =404;
}
Also make sure that no other location block catches the /social/subdir/ request.
Lastly (irrelevant to your question, but very important) remove this line
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
It is totally redundant and evil. try_files
does not miss 404s. Have a look at this for more info IfIsEvil
Upvotes: 1