閱讀771 返回首頁    go 阿裏雲 go 技術社區[雲棲]


護衛神·Nginx大師麵板上如何設置偽靜態

許多客戶在使用護衛神·Nginx大師創建網站後,因SEO要求,可能需要使用偽靜態功能,在這裏護衛神就大體說一下如何設置偽靜態。
本例以安裝wordpress博客程序後設置偽靜態;
一、先打開桌麵上的“護衛神·Nginx大師”,右鍵點擊要設置偽靜態的網站,打開“修改網站”菜單,如下圖所示
1
2

二、勾選 “啟用偽靜態”,同時點擊打開“編輯規則”,在這裏複製wordpress在NGINX下的偽靜態規則,如下圖所示
3
4

“確定”,保存好後,護衛神·Nginx大師會自動重啟服務

三,打開wordpress後台,在WP後台 > 設置 > 固定鏈接,設置為 非默認的即可,如下圖
5

注意事項:
偽靜態規則需要正確的符合NGINX的規則,如果你不會編寫,請聯係程序商那邊索取。如果這裏的規則不正確,保存後將可能導致NGINX無法正常啟動,從而造成網站無法訪問。
DISCUZ_X3.4論壇的NGINX偽靜態規則:
```rewrite ^([^.]*)/topic-(.+).html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^.]*)/article-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^.]*)/forum-(\w+)-([0-9]+).html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^.]*)/group-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^.]*)/space-(username|uid)-(.+).html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^.]*)/blog-([0-9]+)-([0-9]+).html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^.]*)/(fid|tid)-([0-9]+).html$ $1/archiver/index.php?action=$2&value=$3 last;
rewrite ^([^.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
return 404;
}




WORDPRESS博客程序偽靜態規則:
```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環境鏡像(Win2012_64位|PHP|Nginx)
https://market.aliyun.com/products/56368007/cmjj015091.html

護衛神Nginx環境鏡像(Win2008_64位|PHP|Nginx)
https://market.aliyun.com/products/56368007/cmjj014993.html

最後更新:2017-09-06 18:32:43

  上一篇:go  AliCloud Duplicity
  下一篇:go  雲棲蝦米音樂節10月11日陣容大揭秘