cyask3.2本身沒有處理頁面靜態方法,只能自己動手修改模板和添加重寫規則,在這裡向大家介紹下我的處理方法:
1. URL重寫
分別介紹兩個容器的做法(IIS7.5 和 Nginx)
a. IIS7.5: 在IIS7.5中一是使用本身帶有URL重寫組件很方便(可以尋找相關教程),再一個就是使用ISAPI,使用ISAPI時會用到兩個檔案一個是Rewrite.dll用於添加ISAPI篩選器,另一個是httpd.ini用於重寫URL規則,兩個檔案最好都放在網站根目錄下面。好,下面就是httpd.ini中的內容(url重寫規則):
[ISAPI_Rewrite]
RewriteRule (.*)/bid-([0-9]+)\.html $1/browse.php\?sortid=$2
RewriteRule (.*)/bid-([0-9]+)-([0-9]+)\.html $1/browse.php\?sortid=$2&type=$3
RewriteRule (.*)/bid-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/browse.php\?sortid=$2&type=$3&page=$4
RewriteRule (.*)/mid-(.*) $1/member.php\?uid=$2
RewriteRule (.*)/qid-(.*) $1/question.php\?qid=$2
RewriteRule (.*)/nid-(.*) $1/notice.php\?id=$2
b. Nginx: Nginx相對比較簡單,只要在/etc/nginx/sites-enabled/下的網站設定檔中的 server{ 內寫上下面的規則:
rewrite ^(.*)/bid-([0-9]+).html$ $1/browse.php?sortid=$2 last;
rewrite ^(.*)/bid-([0-9]+)-([0-9]+).html$ $1/browse.php?sortid=$2&type=$3 last;
rewrite ^(.*)/bid-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/browse.php?sortid=$2&type=$3&page=$4 last;
rewrite ^(.*)/mid-(.*)$ $1/member.php?uid=$2 last;
rewrite ^(.*)/qid-(.*)$ $1/question.php?qid=$2 last;
rewrite ^(.*)/nid-(.*)$ $1/notice.php?id=$2 last;
2. 修改模板及php檔案
主要修改和重寫相關的URL地址,和以上規則保持一致,下面會列上要修改的模板及php檔案:
a. 模板:/templates/default
browse.html
browse_more.html
index.html
question_nosolve.html
question_share.html
question_solve.html
question_vote.html
search.html
b. php檔案: question.php,response.php,browse.php
所需檔案:
Rewrite.dll:http://files.cnblogs.com/jiangyao/Rewrite.rar
http.ini:http://files.cnblogs.com/jiangyao/httpd.rar
修改後的模板及PHP檔案:http://files.cnblogs.com/jiangyao/%e4%bf%ae%e6%94%b9%e6%96%87%e4%bb%b6.rar
OVER...