Wordpress Multisite: Subsite wp-admin “err_too_many_redirects”

前端 未结 5 2268
挽巷
挽巷 2021-02-14 15:22

i installed a new WordPress 4.1 multisite

I can navegate Front and access to the main site dashboard

http://blog.urlcorrect.com/wp-admin/
5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-14 15:59

    In my case I was using Nginx,

    That means .htaccess won't work, because it's Apache.

    If you're using Nginx, you might want to read the Nginx page of the WordPress Codex: https://codex.wordpress.org/Nginx

    I'll paste the most importants parts here, in case the Codex go offline for whatever reason:

    WordPress Multisite Subdirectory rules

    # WordPress multisite subdirectory rules.
    # Designed to be included in any server {} block.
    
    map $uri $blogname{
        ~^(?P/[^/]+/)files/(.*)       $blogpath ;
    }
    
    map $blogname $blogid{
        default -999;
    
        #Ref: http://wordpress.org/extend/plugins/nginx-helper/
        #include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;
    }
    
    server {
        server_name example.com ;
    
        root /var/www/example.com/htdocs;
        index index.php;
    
        location ~ ^(/[^/]+/)?files/(.+) {
            try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
            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) {
            # Don't use `$uri` here, see https://github.com/yandex/gixy/issues/77
            rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
            rewrite ^(/[^/]+)?(/wp-.*) $2 last;
            rewrite ^(/[^/]+)?(/.*\.php) $2 last;
        }
    
        location / {
            try_files $uri $uri/ /index.php?$args ;
        }
    
        location ~ \.php$ {
            try_files $uri =404;
            include fastcgi_params;
            fastcgi_pass php;
        }
    
        #add some rules for static content expiry-headers here
    }
    

    WordPress Multisite subdomains rules

    map $http_host $blogid {
        default       -999;
    
        #Ref: http://wordpress.org/extend/plugins/nginx-helper/
        #include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;
    
    }
    
    server {
        server_name example.com *.example.com ;
    
        root /var/www/example.com/htdocs;
        index index.php;
    
        location / {
            try_files $uri $uri/ /index.php?$args ;
        }
    
        location ~ \.php$ {
            try_files $uri =404;
            include fastcgi_params;
            fastcgi_pass php;
        }
    
        #WPMU Files
            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;
            }
    
        #WPMU x-sendfile to 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;
        }
    
        #add some rules for static content expiry-headers here
    }
    

    Note: WordPress Network installs no longer need the blogs.dir rules when creating a network, however may still be needed when migrating older installations.

提交回复
热议问题