Skip to content

Instantly share code, notes, and snippets.

@holmesconan
Created December 12, 2016 06:58
Show Gist options
  • Save holmesconan/a199dfd9fb3e3d023e28a04ba9dc4e64 to your computer and use it in GitHub Desktop.
Save holmesconan/a199dfd9fb3e3d023e28a04ba9dc4e64 to your computer and use it in GitHub Desktop.
Nginx Wordpress Rewrite rules.
server {
server_name example.com ;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log debug;
root /var/www/example.com/htdocs ;
index index.php;
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/wordpress(/[^/]+)?(/wp-.*) /wordpress$2 last;
rewrite ^/wordpress(/[^/]+)?(/.*\.php)$ /wordpress$2 last;
}
location / {
try_files $uri $uri/ /wordpress/index.php?$args ;
}
location ~ \.php$ {
try_files $uri /wordpress/index.php;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment