解決WordPress MU搭配Nginx出現頁面跑版

Roy
·
·
IPFS
·

最近閒來無事所以開始研究 WordPress Multisite(WordPress MU)WordPress MU有支援子域名和子目錄兩種功能,不過在設定子目錄就出現問題了。

設定完打開子目錄網站發現網域可以使用,但是版型跑掉了!!

開啟F12檢視一下到底那邊出問題,原來原因是出在css和javascritp套件找不到造成404錯誤

那因為我這邊使採用Nginx作為WebServer,所以要針對Nginx額外設定規則

在nginx.conf和nginx.ssl.conf加入以下程式碼並儲存

if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}

然後輸入以下指令,如果成功會出現successful 字樣

nginx -t

再輸入以下指令進行儲存並重新載入

nginx -s reload

最後切換到網頁並重新刷新頁面就會正常出現了

CC BY-NC-ND 2.0

Like my work? Don't forget to support and clap, let me know that you are with me on the road of creation. Keep this enthusiasm together!

RoyBackend Developer 曾在遊戲公司開發維護金流系統,使用 GCP、Linode 管理Linux伺服器 現在專注在 WordPress開發、代管,有空發表一下技術文章 個人部落格 https://rdfarm.net/
  • Author
  • More

【網域轉移】輕鬆從Godaddy 將網址轉移到NameCheap

將VestaCP 網站搬家到 HestiaCP 全視覺化主機管理工具

解決 WordPress「目前正在執行另一項更新程序」導致無法升級更新的問題