I am running Wordpress through nginx and php-fpm. When a file that exists is requested, it works fine but when try_pass attempts to rewrite the URL to index.php, the browser just downloads the source of the PHP file. How can I get try_files to pass index.php to fastcgi?
Here is my nginx config
server {
listen 80;
listen [::]:80;
root /home/gausie/mywebsite.com/;
index index.php;
server_name mywebsite.com;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
I've basically borrowed this from the nginx wiki so I can't see why it doesn't work!
So... with no changes to the file at all it's fixed itself after just waiting.
I'd appreciate if anyone knows why it took so long to work though...