phpcms在nginx的rewrite偽靜態(tài)標準寫法
發(fā)布時間:2012-09-24 11:51:10 作者:佚名
我要評論
phpcms在nginx的rewrite偽靜態(tài)寫法,網(wǎng)上是亂七八糟的不知道有多少種。有的是直接從apache的規(guī)則修改來的,但這種修改而來的卻不是最標準的
我用的lnmp一鍵安裝包,conf文件是放在默認路徑。在進行測試時,我先使用了
location / {
rewrite ^/caipu-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
rewrite ^/content-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
rewrite ^/list-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&page=$2 last;
rewrite ^/tag-([^\.]*)-([0-9]+)-([0-9]+).html /index.php?m=content&c=tag&catid=$2&tag=$1&page=$3 last;
rewrite ^/comment-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=comment&c=index&a=init&commentid=content_$1-$2-$3 last;
rewrite ^/([^\.]*).html /index.php?m=member&c=index&a=$1 last;
}
然后就出現(xiàn)杯具了。打開網(wǎng)站首頁時提示“Action does not exist.”意思是行為不存在?我翻遍了百度,在phpcms官方論壇有人說這個錯誤是地址問題,再聯(lián)想到我是修改偽靜態(tài)出現(xiàn)的······我懂了,是首頁偽靜態(tài)問題!
在我對照了wordpress官方的寫法后,我TM終于寫成了。。。
location / {
if (!-f $request_filename){
rewrite (.*) /index.php;
}
rewrite ^/caipu-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
rewrite ^/content-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
rewrite ^/list-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&page=$2 last;
rewrite ^/tag-([^\.]*)-([0-9]+)-([0-9]+).html /index.php?m=content&c=tag&catid=$2&tag=$1&page=$3 last;
rewrite ^/comment-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=comment&c=index&a=init&commentid=content_$1-$2-$3 last;
rewrite ^/([^\.]*).html /index.php?m=member&c=index&a=$1 last;
}
復制代碼
代碼如下:location / {
rewrite ^/caipu-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
rewrite ^/content-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
rewrite ^/list-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&page=$2 last;
rewrite ^/tag-([^\.]*)-([0-9]+)-([0-9]+).html /index.php?m=content&c=tag&catid=$2&tag=$1&page=$3 last;
rewrite ^/comment-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=comment&c=index&a=init&commentid=content_$1-$2-$3 last;
rewrite ^/([^\.]*).html /index.php?m=member&c=index&a=$1 last;
}
然后就出現(xiàn)杯具了。打開網(wǎng)站首頁時提示“Action does not exist.”意思是行為不存在?我翻遍了百度,在phpcms官方論壇有人說這個錯誤是地址問題,再聯(lián)想到我是修改偽靜態(tài)出現(xiàn)的······我懂了,是首頁偽靜態(tài)問題!
在我對照了wordpress官方的寫法后,我TM終于寫成了。。。
復制代碼
代碼如下:location / {
if (!-f $request_filename){
rewrite (.*) /index.php;
}
rewrite ^/caipu-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
rewrite ^/content-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
rewrite ^/list-([0-9]+)-([0-9]+).html /index.php?m=content&c=index&a=lists&catid=$1&page=$2 last;
rewrite ^/tag-([^\.]*)-([0-9]+)-([0-9]+).html /index.php?m=content&c=tag&catid=$2&tag=$1&page=$3 last;
rewrite ^/comment-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?m=comment&c=index&a=init&commentid=content_$1-$2-$3 last;
rewrite ^/([^\.]*).html /index.php?m=member&c=index&a=$1 last;
}
相關文章
完美解決phpcms圖片太大撐破表格圖片自適應圖片按比例縮小
下面小編就為大家?guī)硪黄昝澜鉀Qphpcms圖片太大撐破表格圖片自適應圖片按比例縮小。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-10-18- 這篇文章主要介紹了PHPCMS v9 安全設置、防范教程,需要的朋友可以參考下2016-09-05
PHPCMS V9 全站 Sitemaps生成實現(xiàn)代碼[服務器端版]
這篇文章主要介紹了PHPCMS V9 全站 Sitemaps生成實現(xiàn)代碼[服務器端版],需要的朋友可以參考下2016-06-08- 這篇文章主要介紹了phpcms內(nèi)容詳情頁只顯示日期不顯示時間的方法,即格式化時間輸出的方法,需要的朋友可以參考下2015-06-19
- 這篇文章主要介紹了PHPCMS制作網(wǎng)站地圖的簡單方法,本文給出了操作步驟及標簽源碼,需要的朋友可以參考下2015-06-19
- 這篇文章主要介紹了PHPCMSV9父欄目調(diào)用子欄目的方法,本文講解了在二級欄目列表頁調(diào)用、在一級欄目列表頁調(diào)用兩種方法方式,需要的朋友可以參考下2015-06-19
PHPCMS使用date函數(shù)實現(xiàn)自動更新頁腳年月的方法
這篇文章主要介紹了PHPCMS使用date函數(shù)實現(xiàn)自動更新頁腳年月的方法,本文主要還是可以學習到date函數(shù)的用法了,需要的朋友可以參考下2015-06-19- 這篇文章主要介紹了phpsso忘記密碼的解決辦法,本文用PHPCMS的密碼及encrypt值替換數(shù)據(jù)表解決了這個問題,方法還是挺靠譜的,只是操作要求有點,需要的朋友可以參考下2015-06-19
- 這篇文章主要介紹了phpcms 退出無法同步通知discuz問題的解決方法,需要的朋友可以參考下2014-12-15
phpcms v9列表頁如何調(diào)用子欄目如首頁>產(chǎn)品中心>產(chǎn)品類型a
phpcms v9列表頁如何調(diào)用子欄目如:首頁>產(chǎn)品中心>產(chǎn)品類型a>產(chǎn)品類型a11,在列表頁產(chǎn)品類型a中,包括產(chǎn)品類型a1、產(chǎn)品類型a2、產(chǎn)品類型a32014-09-24

