nginx try_files and Wordpress
I am having some difficulty with try_files under nginx. I followed this guide for setting up nginx with PHP and MySQL -
I have a Wordpress blog (in this post I have changed it to example.com for privacy reasons) and it looks like this:
server {
listen 80;
server_name www.example.com example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
location / {
root /srv/www/example.com/public_html;
index index.html index.htm index.php;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/example.com/public_html$fastcgi_script_name;
}
}
Could anyone please tell me how the try_files should be? When I attempt to load the website it simply returns 404. I haven't used nginx in a few years thus any help would be kindly appreciated
Cheers
6 Replies
What is the domain that is actually experiencing this issue?
- Les
No one likes to play twenty-questions.
Is your website private? No? Then if it's public, what difference does it make if you list it here or not?
location / {
[...]
try_files $uri $uri/ /index.php?$args;
}
@vonskippy:
You also "don't see why" your site isn't working.
No one likes to play twenty-questions.
Is your website private? No? Then if it's public, what difference does it make if you list it here or not?
I'm sorry you feel that way.
@sanvila:
You just need this inside the "location /" block:
location / { [...] try_files $uri $uri/ /index.php?$args; }
Thanks! It worked!