cyask3.2偽靜態方法

來源:互聯網
上載者:User

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...

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.