Skip to content

Instantly share code, notes, and snippets.

@apisandipas
Created June 10, 2014 19:45
Show Gist options
  • Select an option

  • Save apisandipas/1f207b77fcdd0c03980e to your computer and use it in GitHub Desktop.

Select an option

Save apisandipas/1f207b77fcdd0c03980e to your computer and use it in GitHub Desktop.
NGINX / WordPress Multisite
map $uri $blogname{
~^(?P<blogpath>/[^/]+/)files/(.*) $blogpath ;
}
map $blogname $blogid{
default -999;
#Ref: http://wordpress.org/extend/plugins/nginx-helper/
#include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;
}
server {
server_name _;
root /home/apps/www/current;
index index.php;
location ~ ^(/[^/]+/)?files/(.+) {
try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
access_log off; log_not_found off; expires max;
}
#avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /home/apps/www/current/wp-content/blogs.dir ;
access_log off; log_not_found off; expires max;
}
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#add some rules for static content expiry-headers here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment