I am basically trying to implement the Apache MultiViews behaviour so that my URLs do not require the .php extension.
As far as I can see from other questions answered here on Server Fault, I should have this problem sorted, but something is clearly wrong in my nginx config.
The behaviour is almost correct;
- I can browse to
/path/to/app/
and the index.php file is correctly parsed - I can browse to
/path/to/app/function.php
and the file is correctly parsed - I can browse to
/path/to/app/media/some.jpg
and it is served as static content - If I browse to
/path/that/doesnt/exist
I get a 404 as expected
However, if I browse to /path/to/function
the try_files
directive correctly matches it to function.php
but downloads it as a static file.
Here is the config file:
server { listen 80; server_name app; root /path/to/app; index index.php index.html index.htm; access_log /var/log/nginx/access.log; location / { allow all; try_files $uri $uri/ $uri.php =404; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; } location ~ /\.ht { deny all; } }