You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.7 KiB
62 lines
1.7 KiB
map $uri $blogname{
|
|
~^(?<blogpath>/[^/]+/)files/(.*) $blogpath;
|
|
}
|
|
|
|
map $blogname $blogid{
|
|
default -999;
|
|
|
|
# Must Read - http://rtcamp.com/tutorials/nginx-maps-wordpress-multisite-static-files-handling/
|
|
# example.com/site1/ 2;
|
|
# example.com/site2/ 3;
|
|
|
|
include /var/www/example.com/htdocs/wp-content/plugins/nginx-helper/map.conf;
|
|
}
|
|
|
|
server {
|
|
server_name example.com;
|
|
|
|
access_log /var/log/nginx/example.com.access.log;
|
|
error_log /var/log/nginx/example.com.error.log;
|
|
|
|
root /var/www/example.com/htdocs;
|
|
index index.php;
|
|
|
|
location ~ ^(/[^/]+/)?files/(?<rt_file>.+) {
|
|
try_files /wp-content/blogs.dir/$blogid/files/$rt_file /wp-includes/ms-files.php?file=$rt_file;
|
|
access_log off; log_not_found off; expires max;
|
|
}
|
|
|
|
#avoid php readfile()
|
|
location ^~ /blogs.dir {
|
|
internal;
|
|
alias /var/www/example.com/htdocs/wp-content/blogs.dir;
|
|
access_log off; log_not_found off; expires max;
|
|
}
|
|
|
|
if (!-e $request_filename) {
|
|
# wp-admin to wp-admin/
|
|
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
|
|
#other wp-* files/folders
|
|
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
|
|
#other php files
|
|
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
|
|
}
|
|
|
|
location / {
|
|
try_files $uri $uri/ /index.php?$args;
|
|
}
|
|
|
|
location ~ \.php$ {
|
|
try_files $uri /index.php;
|
|
include fastcgi_params;
|
|
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
}
|
|
|
|
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 = /favicon.php { access_log off; log_not_found off; }
|
|
location = /robots.txt { access_log off; log_not_found off; }
|
|
location ~ /\. { deny all; access_log off; log_not_found off; }
|
|
}
|
|
|