WordPress Multisite-静态内容-找不到404

WordPress Multisite-静态内容-找不到404,wordpress,nginx,Wordpress,Nginx,我已经在名为/WordPressDemo的子目录中安装了一个Wordpress。 有一个名为demo.example.com的域,其文档根/表示您需要输入demo.example.com/WordPressDemo才能访问WordPress 我使用nGINX会带来很多麻烦,我设法让基本链接(例如永久链接)正常工作,因此多站点本身也正常工作,唯一的问题是它从错误的路径请求静态数据 例如: 它要求: 但我们应该要求 我当前的nginx指令: 你调查过了吗 无论如何,您可能有兴趣修改此代码: # Wo

我已经在名为/WordPressDemo的子目录中安装了一个Wordpress。 有一个名为demo.example.com的域,其文档根/表示您需要输入demo.example.com/WordPressDemo才能访问WordPress

我使用nGINX会带来很多麻烦,我设法让基本链接(例如永久链接)正常工作,因此多站点本身也正常工作,唯一的问题是它从错误的路径请求静态数据

例如:

它要求:

但我们应该要求

我当前的nginx指令:

你调查过了吗

无论如何,您可能有兴趣修改此代码:

# WordPress multisite subdirectory rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
        index index.php;
        try_files $uri $uri/ /index.php?$args;
}

# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
         expires 24h;
         log_not_found off;
}

location ~ ^/[_0-9a-zA-Z-]+/files/(.*)$ {
        try_files /sites/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
        access_log off; log_not_found off; expires max;
}

#avoid php readfile()
location ^~ /sites {
        internal;
        alias /var/www/mu/sites ;
        access_log off; log_not_found off;      expires max;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-ms-subdir-wp-super-cache.conf;
#include global/wordpress-ms-subdir-w3-total-cache.conf;

# Rewrite multisite '.../wp-.*' and '.../*.php'.
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;
}

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
         # Zero-day exploit defense.
         # http://forum.nginx.org/read.php?2,88845,page=3
         # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
         # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
         try_files $uri =404;

         fastcgi_split_path_info ^(.+\.php)(/.+)$;


         include fastcgi_params;
         fastcgi_pass 127.0.0.1:9000;

         fastcgi_cache_bypass $no_cache
         fastcgi_cache_bypass $no_cache;
         fastcgi_no_cache $no_cache;

         fastcgi_cache WORDPRESS;
         fastcgi_cache_valid  6000m;
}

location ~ /purge(/.*) {
        fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
} 

它回答了你的问题吗?

静态文件有404吗?当然,位置错了。真的吗?没有人能做到真的很遗憾,甚至连赏金都没有给我一个解决办法:不,复制粘贴的东西帮不了我。我需要一个熟悉nginx和wordpress的人。
# WordPress multisite subdirectory rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
        index index.php;
        try_files $uri $uri/ /index.php?$args;
}

# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
         expires 24h;
         log_not_found off;
}

location ~ ^/[_0-9a-zA-Z-]+/files/(.*)$ {
        try_files /sites/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
        access_log off; log_not_found off; expires max;
}

#avoid php readfile()
location ^~ /sites {
        internal;
        alias /var/www/mu/sites ;
        access_log off; log_not_found off;      expires max;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-ms-subdir-wp-super-cache.conf;
#include global/wordpress-ms-subdir-w3-total-cache.conf;

# Rewrite multisite '.../wp-.*' and '.../*.php'.
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;
}

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
         # Zero-day exploit defense.
         # http://forum.nginx.org/read.php?2,88845,page=3
         # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
         # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
         try_files $uri =404;

         fastcgi_split_path_info ^(.+\.php)(/.+)$;


         include fastcgi_params;
         fastcgi_pass 127.0.0.1:9000;

         fastcgi_cache_bypass $no_cache
         fastcgi_cache_bypass $no_cache;
         fastcgi_no_cache $no_cache;

         fastcgi_cache WORDPRESS;
         fastcgi_cache_valid  6000m;
}

location ~ /purge(/.*) {
        fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}