Skip to content

Instantly share code, notes, and snippets.

@tmort
Created September 16, 2013 16:24
Show Gist options
  • Save tmort/6582961 to your computer and use it in GitHub Desktop.
Save tmort/6582961 to your computer and use it in GitHub Desktop.
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 {
listen 80;
server_name example.com ;
root /var/www/vhosts/example.com/html;
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 /var/www/vhosts/example.com/html/content/uploads ;
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
}
@ReallyBean
Copy link

Hello
Would you like to tell me how to set up nginx conf of ​multisite in WordPress installed in the subdirectory of domain using Nginx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment