gpt4 book ai didi

WordPress Multisite 目录 nginx 配置

转载 作者:行者123 更新时间:2023-12-01 00:54:20 25 4
gpt4 key购买 nike

我正在尝试使用 nginx 后面的子目录设置 WordPress Multisite。

最初我的 WordPress 托管在 https://example.com/wordpress ,现在我将其移至多站点。
wp-config.php看起来不错:

define('WP_DEBUG', false);
define( 'WP_ALLOW_MULTISITE', true );

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'example.com');
define('PATH_CURRENT_SITE', '/wordpress/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1); `

我的 nginx.conf是:
server { 
listen 80;
server_name example.com;

root /var/www/; # wordpress is at /var/www/wordpress, All wp files are in this wordpress folder
index index.php;

access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;

recursive_error_pages on;

location / {
try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Pass uploaded files to wp-includes/ms-files.php.
rewrite /files/$ /wordpress/index.php last;

if ($uri !~ wp-content/plugins) {
rewrite /files/(.+)$ /wordpress/wp-includes/ms-files.php?file=$1 last;
}

# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite_log on;
rewrite ^/(/[^/]+)?(/wp-.*) wordpress/$2 last;
rewrite ^/(/[^/]+)?(/.*\.php) wordpress/$2 last;

# rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
# rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}

location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}

location ~ \.php$ {
set $skip_cache 0;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;

if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}

fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache microcache;
fastcgi_cache_valid 200 5m;
}
}

我创建了一个现在称为“Site2”的网站: https://example.com/wordpress/site2
但是这个网站没有正确加载页面。当我查看 https://example.com/wordpress/site2/wp-admin/我收到错误:

This webpage has a redirect loop.



立即提供帮助将不胜感激。

最佳答案

好的,如果您希望您的网站运行

https://example.com/site1

https://example.com/site2

这是你可以做的,

转到网络设置>站点
将 site2 地址从/wordpress/site2 更改为/site2

另外你需要修复,nginx配置如下

# rewrite ^/(/[^/]+)?(/wp-.*) wordpress/$2 last;
# rewrite ^/(/[^/]+)?(/.*\.php) wordpress/$2 last;

rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) /wordpress$1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ /wordpress$1 last;

那就是您需要使用未注释的代码,并进行一些修复

关于WordPress Multisite 目录 nginx 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29123222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com