---
title: "ISAPI_REWRITE3动态页面URL做301到静态页面"
author: "wtx358"
date: "2012-08-21T12:05:44Z"
tags: []
categories: ["互联网"]
slug: "isapi-rewrite3-url-301"
draft: false
lastmod: "2012-08-21T12:05:44Z"
id: 1644122
url: "https://wtx358.iteye.com/blog/1644122"
---

我网站原来是动态的，现在我改成生成静态了，我想把原来动态的页面用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]