Nginx-不同子目录中的多个WordPress站点-/wp admin重定向循环

Nginx-不同子目录中的多个WordPress站点-/wp admin重定向循环,wordpress,nginx,Wordpress,Nginx,我正试图用Nginx在三个不同的目录中托管三个单独的WordPress站点。经过数小时的研究,我完全无法找到一种配置,允许我访问/wp admin和网站上的各种页面 以下是我目前的情况: server { listen 80; listen [::]:80 ipv6only=on; root /var/www; server_name my.ip.add.ress; location /wp1 {

我正试图用Nginx在三个不同的目录中托管三个单独的WordPress站点。经过数小时的研究,我完全无法找到一种配置,允许我访问
/wp admin
和网站上的各种页面

以下是我目前的情况:

server {
        listen 80;
        listen [::]:80 ipv6only=on;

        root /var/www;
        server_name my.ip.add.ress;

        location /wp1 {
            root /var/www/wp1;
            index index.php index.html index.htm;
            try_files $uri $uri/ /wp1/index.php?q=$args;
        }

        location /wp2 {
            root /var/www/wp2;
            index index.php index.html index.htm;
            try_files $uri $uri/ /wp2/index.php?q=$args;
        }

        location /wp3 {
            root /var/www/wp3;
            index index.php index.html index.htm;
            try_files $uri $uri/ /wp3/index.php?q=$args;
        }

        if (!-e $request_filename) {
            rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
            rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
            rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
        }   

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/html;
        }

        location ~ \.php$ {

                try_files           $uri =404;

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

                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

                fastcgi_cache moodle;
                fastcgi_cache_valid 200 60m;

                fastcgi_read_timeout 3600;
        }

        # Cache static content
        location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
                expires 365d;
        }
}

当我尝试访问/wp admin时,我的浏览器陷入重定向循环。使用重写日志不会产生任何输出。

在您的问题中,您有以下几点:

root /var/www;
...
location /wp1 {
    root /var/www/wp1;
    ...
}
/wp1/foo
的路径名解析为
/var/www/wp1/wp1/foo
。请注意,您在路径名中添加了第二个
/wp1/
术语

location/wp1内部,根目录不变。您不需要在每个位置内指定
root
,因为它仍然是
root/var/www将从外部块继承

删除以下行:

root /var/www/wp1; 
root /var/www/wp2; 
root /var/www/wp3; 
更多信息,请参阅