我无法在Wordpress多站点网络中正确提供静态内容。
但是,当我尝试使用 http://test.com/subsite3/wp-content/uploads/sites/3/2018/05/test.jpg 之类的文件时,它将通过php提供服务。 这是old configuration 并且不再像在wordpress 4.9.6上那样工作,则没有文件夹blogs.dir,文件等。
我在nginx中具有以下配置。请帮助我,因为网站上有很多静态内容,并且服务器不时关闭。
map $uri $blogname{
~^(?<blogpath>/[^/]+/)wp-content/(.*) $blogpath ;
}
map $blogname $blogid{
default -999;
include /var/www/webroot/ROOT/wp-content/uploads/nginx-helper/map.conf ;
}
server {
listen 80 default_server;
server_name localhost;
server_name_in_redirect off;
root /var/www/webroot/ROOT;
index index.php;
if ($http_x_remote_port = '' ) {
set $http_x_remote_port $remote_port;
}
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;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't b$
try_files $uri $uri/ /index.php?$args;
auth_basic "Restricted content";
auth_basic_user_file /var/www/webroot/.htpasswd;
}
location ~ ^(/[^/]+/)?wp-content/(?<rt_file>.+) {
try_files /wp-content/uploads/sites/$blogid/$rt_file /wp-includes/ms-files.php?file=$rt_file ;
access_log off; log_not_found off; expires max;
}
location ~ \.php$ {
try_files $uri =404;
# location ~ /\. { deny all; access_log off; log_not_found off; }
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
}