所以我最近遇到了这个问题,我在主域中有一个 WordPress 站点,而另一个 WordPress 安装在主安装中的子目录/文件夹中。主站点工作正常,管理面板等,但当你试图改变永久链接,一切都有一个 404 错误。
我注意到所有的请求都被路由回主域 (没有额外的文件夹),所以我猜想它可能与 nginx 有关,最有可能是这样的:
location / {
# This is cool because no php is touched for static content
try_files $uri $uri/ /index.php?$query_string;
}
这打破了文件夹内的重写并将所有内容发送到主站点,以使其工作,我不得不为子目录添加几个位置指令 – 现在所有不同类型的固定链接配置都可以工作。
这让网站工作得很好:
location /subinstall {
root /home/maindomain.com/public_html/subinstall;
index index.php index.html index.htm;
try_files $uri $uri/ @wp;
}
location @wp {
rewrite ^/subinstall(.*) /subinstall/index.php?q=$1;
}
使用 /subinstall 作为第二个 WordPress 安装的子文件夹的名称。