nginx wordpress multisite code example
Example 1: wordpress multi site cofiguration with nginx
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ ^/files/(.*)$ {
try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
access_log off; log_not_found off; expires max;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
location ^~ /blogs.dir {
internal;
alias /var/www/pathtoyoursite/web/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 ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
Example 2: wordpress multi site cofiguration with nginx
map $http_host $blogid {
default 0;
include /var/www/pathtoyoursite/wp-content/uploads/nginx-helper/map.conf;
}