isapi_rewrite3 實現站內任意動態頁僞靜態

我網站原來是動態的,現在我改成生成靜態了,我想把原來動態的頁面用301重定向到現在的靜態頁面。
可是動態頁面中的問號一直出錯。
下面是我寫的
動態頁面是:news.asp?cat=1
靜態頁面是:news_1.html
我想把動態頁面定向到靜態頁面。
下面是寫的規則
RewriteRule ^/news\.asp\?cat=([0-9]*)$ /news_$1\.html [R=301]
這個規則得到的結果是:
new_1.html?cat=1
但是這個不是我想要的結果 。

解決辦法如下:
在研究了ISAPI_Rewrite3的規則之後得出如下結論:
這個規則的正確寫法是(紅字部分):
RewriteCond %{QUERY_STRING} ^cat=(\d+)$ 
RewriteRule ^/news\.asp$ /news_%1.html? [R=301,O]
得到的結果是news_1.html

 

#示例:把幾個動態URL做301轉移到靜態頁面上

RewriteCond %{QUERY_STRING} ^id=1210$ 

RewriteRule ^/Item/list\.asp /html/zx/zx_1210.html? [NC,L,R=301,O]

RewriteCond %{QUERY_STRING} ^id=1165$ 

RewriteRule ^/Item/list\.asp /html/News/xwdt_1165.html? [NC,L,R=301,O]

RewriteCond %{QUERY_STRING} ^id=1254$ 

RewriteRule ^/Item/list\.asp /html/qggwypx/xw_1254.html? [NC,L,R=301,O]

 

 

 

 

參考文章:

1、http://wtx358.iteye.com/blog/1644122

2、http://www.steveluo.name/isapi-rewrite-301-move-permanently-redirect/

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章