asp的程序能實現(xiàn)偽靜態(tài)化的方法
更新時間:2007年03月08日 00:00:00 作者:
安裝說明:
1、在IIS的Isapi上添加這個篩選器,篩選器名稱 re,可執(zhí)行文件選擇 Rewrite.dll?。?
2、設(shè)置httpd.ini文件
RewriteRule /news/(\d+)\.html /jsp/news\.jsp\?id=$1 [N,I]
表示將news.jsp?id=95 轉(zhuǎn)換成news/95.html
以此類推,如果你有更多的參數(shù),則增加相應(yīng)的(\d+),而后面的id=$1,則增加id=$2,等等。
目前較為普遍的動態(tài)網(wǎng)頁包括asp,php,jsp,shtml,jhtml,cgi......甚至還有一些自己定義的,比如:aspx,do,index,hello等等。表現(xiàn)形式為:news.asp?id=95。建議讀者通過re_write將其轉(zhuǎn)換成news/95.html,以便于google對改網(wǎng)頁的識別。
re_write是iis里的一個模塊,你可以從http://www.ZZcoo.com/re_write.zip下載,里面有相關(guān)安裝說明。
當(dāng)需要將news.jsp?id=95的映射成news/95.html時,只需設(shè)置httpd.ini文件:
RewriteRule /news/(\d+)\.html /news\.jsp\?id=$1 [N,I]
這樣就把 /news/95.html 這樣的請求映射成了 /news.jsp?id=95
然后你在連接處這樣寫:<a href='/news/95.html'>95新聞</a>。
如果你的新聞是通過數(shù)據(jù)庫循環(huán)讀取出來的,那么寫法是:
while(rs.next())
{
String id = (String)rs.getString('id');
out.print('<a hef='/news/''+id+'.html>');
out.print('95新聞');
out.print('</a>');
}
如果你在處理數(shù)據(jù)翻頁,那么寫法是:
More_<%=Page%>_<%=type%>.html (注:page是翻頁頁數(shù),type是數(shù)據(jù)類型)
表現(xiàn)形式:More_1_95.html
如果翻下一頁,則為:More_2_95.html,繼續(xù)下一頁的循環(huán),則是:
More_3_95.html,以此類推。
不過你需要在httpd.ini文件中增加以下代碼:
RewriteRule /More_(\d+)_(\d+)\.html /jsp/more\.jsp\?page=$1&type=$2 [N,I]
如果你的動態(tài)程序有多個參數(shù)需要傳遞,那么就增加多個(\d+)即可,如下:
RewriteRule /More_(\d+)_(\d+)_(\d+)\.html /jsp/more\.jsp\?page=$1&type=$2&type2=$3 [N,I]
翻頁處理表現(xiàn)形式是:More_1_95.html
1、在IIS的Isapi上添加這個篩選器,篩選器名稱 re,可執(zhí)行文件選擇 Rewrite.dll?。?
2、設(shè)置httpd.ini文件
RewriteRule /news/(\d+)\.html /jsp/news\.jsp\?id=$1 [N,I]
表示將news.jsp?id=95 轉(zhuǎn)換成news/95.html
以此類推,如果你有更多的參數(shù),則增加相應(yīng)的(\d+),而后面的id=$1,則增加id=$2,等等。
目前較為普遍的動態(tài)網(wǎng)頁包括asp,php,jsp,shtml,jhtml,cgi......甚至還有一些自己定義的,比如:aspx,do,index,hello等等。表現(xiàn)形式為:news.asp?id=95。建議讀者通過re_write將其轉(zhuǎn)換成news/95.html,以便于google對改網(wǎng)頁的識別。
re_write是iis里的一個模塊,你可以從http://www.ZZcoo.com/re_write.zip下載,里面有相關(guān)安裝說明。
當(dāng)需要將news.jsp?id=95的映射成news/95.html時,只需設(shè)置httpd.ini文件:
RewriteRule /news/(\d+)\.html /news\.jsp\?id=$1 [N,I]
這樣就把 /news/95.html 這樣的請求映射成了 /news.jsp?id=95
然后你在連接處這樣寫:<a href='/news/95.html'>95新聞</a>。
如果你的新聞是通過數(shù)據(jù)庫循環(huán)讀取出來的,那么寫法是:
while(rs.next())
{
String id = (String)rs.getString('id');
out.print('<a hef='/news/''+id+'.html>');
out.print('95新聞');
out.print('</a>');
}
如果你在處理數(shù)據(jù)翻頁,那么寫法是:
More_<%=Page%>_<%=type%>.html (注:page是翻頁頁數(shù),type是數(shù)據(jù)類型)
表現(xiàn)形式:More_1_95.html
如果翻下一頁,則為:More_2_95.html,繼續(xù)下一頁的循環(huán),則是:
More_3_95.html,以此類推。
不過你需要在httpd.ini文件中增加以下代碼:
RewriteRule /More_(\d+)_(\d+)\.html /jsp/more\.jsp\?page=$1&type=$2 [N,I]
如果你的動態(tài)程序有多個參數(shù)需要傳遞,那么就增加多個(\d+)即可,如下:
RewriteRule /More_(\d+)_(\d+)_(\d+)\.html /jsp/more\.jsp\?page=$1&type=$2&type2=$3 [N,I]
翻頁處理表現(xiàn)形式是:More_1_95.html
相關(guān)文章
Insert Date and Time into Access
Insert Date and Time into Access...2007-04-04ASP javascript Application對象的Contents和StaticObjects做Cache的一些
ASP javascript: Application對象的Contents和StaticObjects做Cache的一些結(jié)論。 ASP封裝Cache對象,一般都是基于Application的,2008-05-05asp中用insert into語句向數(shù)據(jù)庫插入記錄(添加信息)的方法
asp中用insert into語句向數(shù)據(jù)庫插入記錄信息的方法,學(xué)習(xí)的朋友可以參考下。2010-09-09ASP+JS三級聯(lián)動下拉菜單[調(diào)用數(shù)據(jù)庫數(shù)據(jù)]
ASP+JS三級聯(lián)動下拉菜單[調(diào)用數(shù)據(jù)庫數(shù)據(jù)]...2007-03-03