Last Updated: February 25, 2016
·
980
· pothi

WordPress Nginx config

Traditionally, a typical nginx location block for a WordPress site looks like this...

location {
  try_files $uri $uri/ /index.php?$args;
}

However, there is one caveat in it. If $args doesn't exist, then the question mark is appended to /index.php for no reason. So, we can use a variable named $is_args that has the value of "?", only when the arguments are found. So, here's the neat solution / tip...

location {
  try_files $uri $uri/ /index.php$is_args$args;
}

Ref: http://wiki.nginx.org/HttpCoreModule#.24is_args