admin管理员组文章数量:1122846
I have a multisite installation that seems to be working just fine for the first site, but for the second site, the admin panel results in a "too many redirects" loop. What is the correct nginx or wordpress configuration to get this to work?
I have a non-WordPress installation at example
My first blog is setup at example/blog
My second blog is setup to be example/blog/tr
. The frontend renders just fine.
The admin for the first site works just fine, as does the network admin panel.
So and
/
result in pages that work fine. The url results in too many redirects, though.
My nginx configuration for the wp-admin sections looks like this
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite /wp-admin$ $host/$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*.php) $2 last;
}
Here are my wp_blogs and wp_site tables
mysql> SELECT * FROM wp_site;
+----+-------------+--------+
| id | domain | path |
+----+-------------+--------+
| 1 | example | /blog/ |
+----+-------------+--------+
mysql> SELECT blog_id, site_id, domain, path FROM wp_blogs;
+---------+---------+-------------+-----------+
| blog_id | site_id | domain | path |
+---------+---------+-------------+-----------+
| 1 | 1 | example | /blog/ |
| 2 | 1 | example | /blog/tr/ |
+---------+---------+-------------+-----------+
wp-config.php
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'example' );
define( 'PATH_CURRENT_SITE', '/blog/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
I've tried changing the path for the second blog, to something with a different path like /blg/tr
in case it was a path collision error, and I was still getting the problem. I also tried creating a second site in wp_sites and associating the second blog with that second site, also didn't do anything different.
I also put in specific nginx location blocks for specifically /blog/tr/wp-admin
and that seemed to break it more in different ways.
Is there anything I am missing or additional documentation that I am not finding to help debug my second site's wp-admin section?
Reviewed documentation / suggested steps:
/
Trying to access second site dashboard on a multisite configuration proceeds to an error
/
EDIT: Full nginx config
server {
listen 80;
listen 443 ssl;
## Your website name goes here.
server_name example;
## Your only path reference.
root /Users/lfarr/Sites/blog;
## This should be in your http block and if it is, it's not needed here.
index index.php;
ssl_certificate /usr/local/etc/nginx/ssl/example+4.pem;
ssl_certificate_key /usr/local/etc/nginx/ssl/example+4-key.pem;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite /wp-admin$ $host/$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*.php) $2 last;
}
#avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /var/www/example/htdocs/wp-content/blogs.dir ;
access_log off; log_not_found off; expires max;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass fastcgi_backend;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
I have a multisite installation that seems to be working just fine for the first site, but for the second site, the admin panel results in a "too many redirects" loop. What is the correct nginx or wordpress configuration to get this to work?
I have a non-WordPress installation at example.com
My first blog is setup at example.com/blog
My second blog is setup to be example.com/blog/tr
. The frontend renders just fine.
The admin for the first site works just fine, as does the network admin panel.
So https://example.com/blog/wp-admin
and https://example.com/blog/wp-admin/network/
result in pages that work fine. The url https://example.com/blog/tr/wp-admin
results in too many redirects, though.
My nginx configuration for the wp-admin sections looks like this
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite /wp-admin$ $host/$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*.php) $2 last;
}
Here are my wp_blogs and wp_site tables
mysql> SELECT * FROM wp_site;
+----+-------------+--------+
| id | domain | path |
+----+-------------+--------+
| 1 | example.com | /blog/ |
+----+-------------+--------+
mysql> SELECT blog_id, site_id, domain, path FROM wp_blogs;
+---------+---------+-------------+-----------+
| blog_id | site_id | domain | path |
+---------+---------+-------------+-----------+
| 1 | 1 | example.com | /blog/ |
| 2 | 1 | example.com | /blog/tr/ |
+---------+---------+-------------+-----------+
wp-config.php
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'example.com' );
define( 'PATH_CURRENT_SITE', '/blog/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
I've tried changing the path for the second blog, to something with a different path like /blg/tr
in case it was a path collision error, and I was still getting the problem. I also tried creating a second site in wp_sites and associating the second blog with that second site, also didn't do anything different.
I also put in specific nginx location blocks for specifically /blog/tr/wp-admin
and that seemed to break it more in different ways.
Is there anything I am missing or additional documentation that I am not finding to help debug my second site's wp-admin section?
Reviewed documentation / suggested steps:
https://wordpress.org/support/article/debugging-a-wordpress-network/
https://www.wpbeginner.com/wp-tutorials/how-to-install-and-setup-wordpress-multisite-network
https://gist.github.com/JustThomas/141ebe0764d43188d4f2
Trying to access second site dashboard on a multisite configuration proceeds to an error
https://docs.bitnami.com/aws/how-to/troubleshoot-wordpress-issues/
EDIT: Full nginx config
server {
listen 80;
listen 443 ssl;
## Your website name goes here.
server_name example.com;
## Your only path reference.
root /Users/lfarr/Sites/blog;
## This should be in your http block and if it is, it's not needed here.
index index.php;
ssl_certificate /usr/local/etc/nginx/ssl/example.com+4.pem;
ssl_certificate_key /usr/local/etc/nginx/ssl/example.com+4-key.pem;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite /wp-admin$ $host/$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*.php) $2 last;
}
#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;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass fastcgi_backend;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Share
Improve this question
edited Dec 14, 2021 at 22:42
loganfarr
asked Dec 8, 2021 at 18:37
loganfarrloganfarr
514 bronze badges
2
- Can you please share your current nginx config ? Please check if it matches wordpress.org/support/article/nginx – Mohammad Qasim Commented Dec 13, 2021 at 17:52
- @MohammadQasim Thanks for the feedback, full nginx config added. – loganfarr Commented Dec 14, 2021 at 22:42
1 Answer
Reset to default 0There seems to be some issue the the nginx config. Is there any reason you have modified this rule differently then as documented in the wordpress documentation ? (https://wordpress.org/support/article/nginx/#wordpress-multisite-subdirectory-rules)
I am specifically talking about following rule :
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite /wp-admin$ $host/$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*.php) $2 last;
}
I think you can remove the 3rd line in the above rule ( rewrite /wp-admin$ $host/$uri/ permanent;
) as it's not there in the documentation too .. and I think all needed is already there in the first rule of this block.
Beside that in the last rule (rewrite ^(/[^/]+)?(/.*.php) $2 last;
) is missing an escape sequence, which is also present in the documentation.
So Can you try replacing the above block completely as present in the document like shown below ?
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
本文标签: WordPress multisite second site admin resulting in too many redirects error
版权声明:本文标题:WordPress multisite second site admin resulting in too many redirects error 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736293203a1929096.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论