所以我最近遇到了這個問題,我在主域中有一個 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 安裝的子文件夾的名稱。