Nginx怎么設置wordpress偽靜態

首先,在nginx中的server模塊配置如下內容:

location?/?{ ??if?(-f?$request_filename/index.html){ ??????????rewrite?(.*)?$1/index.html?break; ??????} ??if?(-f?$request_filename/index.php){ ??????????rewrite?(.*)?$1/index.php; ??????} ??if?(!-f?$request_filename){ ??????????rewrite?(.*)?/index.php; ??????} ??}

配置完成后,重啟nginx

然后,在wordpress博客后臺的“設置”——“固定鏈接”,自定義結構(我的設置為:/%category%/%post_id%.html 即:分類/文章id.html),如圖:

Nginx怎么設置wordpress偽靜態

至此,WordPress博客偽靜態設置完成。

下面大致講一下固定鏈接設置參數:

1. %year% 基于文章發布年份,比如2007;
2. %monthnum% 基于文章發布月份,比如05;
3. %day% 基于文章發布當日,比如28;
4. %hour% 基于文章發布小時數,比如15;
5. %minute% 基于文章發布分鐘數,比如43
6. %second% 基于文章發布秒數,比如33
7. %postname% 基于文章的postname,其值為撰寫時指定的縮略名,不指定縮略名時是文章標題;
8. %post_id% 基于文章post_id,比如423;
9. %category% 基于文章分類,子分類會處理成“分類/子分類”這種形式;
10. %author% 基于文章作者名。

將上述參數進行組合,即可得到wordpress的固定鏈接形式。網上常見的幾種設置方法:
/%year%/%monthnum%/%day%/%postname%/
/%year%/%monthnum%/%postname%/
/%year%/%monthnum%/%day%/%postname%.html
/%year%/%monthnum%/%postname%.html
/%category%/%postname%.html
/%category%/%post_id%
/%postname%.html
/%post_id%.html 我們一般使用這個方式比較好。

? 版權聲明
THE END
喜歡就支持一下吧
點贊5 分享