Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
map $uri $blogname{
~^(?P<blogpath>/[^/]+/)files/(.*) $blogpath ;
map $blogname $blogid{
default -999;
#include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;
server {
listen 80;
server_name ;
root /var/www/vhosts/;
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 {
alias /var/www/vhosts/ ;
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 ;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
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
You can’t perform that action at this time.