diff --git a/roles/nginx/templates/vhost.conf.j2 b/roles/nginx/templates/vhost.conf.j2 index e8ac56b..6d9fcc1 100644 --- a/roles/nginx/templates/vhost.conf.j2 +++ b/roles/nginx/templates/vhost.conf.j2 @@ -1,6 +1,7 @@ {% set domain_name = item.nginx_domain_name %} {% set domain_aliases = item.nginx_domain_aliases | default("") %} {% set use_https = item.use_https | default("no") %} +{% set has_wordpress = item.has_wordpress | default("no") %} {% if use_https == "yes" %} # http -> https vhost @@ -34,9 +35,9 @@ server { {% include 'https.j2' %} {% endif %} - location / { - try_files $uri $uri/ =404; - } + {% if has_wordpress == "yes" %} + {% include 'wordpress.j2' %} + {% endif %} error_page 500 502 503 504 /50x.html; location = /50x.html { diff --git a/roles/nginx/templates/wordpress.j2 b/roles/nginx/templates/wordpress.j2 new file mode 100644 index 0000000..5ec08c7 --- /dev/null +++ b/roles/nginx/templates/wordpress.j2 @@ -0,0 +1,10 @@ + + # try for WordPress index.php in / + # fall back to index.php + args (passed to php5-fpm later) + location / { + try_files $uri $uri/ /index.php?$args; + } + + # Add trailing slash to */wp-admin requests. + rewrite /wp-admin$ $scheme://$host$uri/ permanent; +