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

