我有一个多站点安装,第一个站点似乎运行得很好,但第二个站点的管理面板结果是;重定向太多“;环要使其工作,正确的nginx或wordpress配置是什么?
我在以下位置安装了非WordPressexample.com
我的第一个博客设置在example.com/blog
我的第二个博客设置为example.com/blog/tr
. 前端渲染刚刚好。
第一个站点的管理员工作正常,网络管理面板也工作正常。所以https://example.com/blog/wp-admin
和https://example.com/blog/wp-admin/network/
生成工作正常的页面。urlhttps://example.com/blog/tr/wp-admin
但会导致太多重定向。
我的wp admin部分的nginx配置如下所示
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;
}
以下是我的wp\\U博客和wp\\U站点表
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配置。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 );
我已经尝试将第二个博客的路径更改为其他路径,如
/blg/tr
如果是路径冲突错误,我仍然会遇到问题。我还尝试在wp\\U站点中创建第二个站点,并将第二个博客与第二个站点相关联,也没有做任何不同。
我还专门为/blog/tr/wp-admin
这似乎以不同的方式打破了它。
是否有我丢失的任何东西或其他文档,我没有找到来帮助调试我的第二个站点的wp管理部分?
审查文件/建议步骤:
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/
编辑:完整nginx配置
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;
}
}