1.下载ISAPI_Rewrite
2.安装.msi的文件
3.接下来一步比较重要哦,看仔细喽.打开Internet 信息服务,右键,web站点属性,ISAPI筛选器选项卡.添加筛选器,名称自己填,路径自己指定ISAPI_Rewrite.dll,然后确定.
4.这一步很重要哦,开始添加rewrite规则.正则,好头痛,
找到ISAPI_Rewrite目录,把httpd.ini的只读属性去掉,打开编辑.
RewriteRule /news_(\d+)\.html /news\.asp\?id=$1 [N,I]
news.asp?id=1 → news_1.html
RewriteRule /list_(\d+)\.html /list\.asp\?$1 [N,I]
list.asp?25 → list_25.html
RewriteRule /list_(\d+)_(\d+)\.html /list\.asp\?$1-$2 [N,I]
list.asp?25-2 → list_25_2.html
RewriteRule /list_(\d+)_(\d+)\.html /list_\.asp\?page=$1&type=$2 [N,I]
list.asp?page=1&type=2 → list_1_2.html
如果想把 www.xxx.com/news.asp?id=888#abc 转换成静态的网页
因为#abc是程序处理了ID=888这个变量生成静态页面之后按锚点又做了一次页内链接,所以应该这么做映射
www.xxx.com/news.asp?id=888#abc转换成www.xxx.com/news_888.htm#abc,重写规则如下:
RewriteRule /news_(\d+)\.htm#(\d+) /news\.asp\?id=$1#$2 [N,I]