君子博学而日参省乎己 则知明而行无过矣

博客园 首页 新随笔 联系 订阅 管理
1. 下载 ISAPI_Rewrite 我这里的 1.3
2. 进入iis 信息管理器,点网站-->属性-->ISAPI删除原来的筛选器
3. 点击某个站点-->属性-->添加ISAPI筛选器,我的原则是放到各自己自己的站点下,如在站点里建一个目录ISAPI_Rewrite,然后把 ISAPI_Rewrite.dll 和 httpd.ini 放这里
4. 配置好重启一下 iis ,接下来就是调试 httpd.ini 了,
5. 调试httpd.ini 不需要重启 iis 和站点
6. httpd.ini 编写规则需要注意的是: .?这些要转义 \.\?
例子:

[ISAPI_Rewrite]

# 3600 = 1 hour
CacheClockRate 3600

RepeatLimit 32
#RewriteCond %{REQUEST_URI} !/(.*)_([0-9]+).*\.html$

RewriteRule /auction_(.*)_([0-9]+).*\.html$ /productdetails\.php\?aid=$2 [L]
RewriteRule /all_auctions_([0-9]+)_([0-9]+)_EndedAuction.*\.html$ /allauctions\.php\?pgno2=$2&id=$1&hashtag=EndedAuction
RewriteRule /all_auctions_([0-9]+)_([0-9]+)_FutureAuction.*\.html$ /allauctions\.php\?pgno3=$2&id=$1&hashtag=FutureAuction
RewriteRule /all_auctions_([0-9]+)_([0-9]+).*\.html$ /allauctions\.php\?pgno=$2&id=$1
RewriteRule /all_auctions_([0-9]+)_(.*).*\.html$ /allauctions\.php\?pgno=$1&st=$2
RewriteRule /all_auctions_([0-9]+).*\.html$ /allauctions\.php\?id=$1
RewriteRule /all_auctions_([0-9]+)_([0-9]+)_VIP.*\.html$ /allauctions\.php\?id=$1&vid=$2
RewriteRule /all_ended_auctions_([0-9]+)_([0-9]+)_([a-zA-Z]).*\.html$ /allauctions\.php\?aid=$1&pgno2=$2&hashtag=$3
RewriteRule /all_future_auctions_([0-9]+)_([0-9]+)_([a-zA-Z]).*\.html$ /allauctions\.php\?aid=$1&pgno3=$2&hashtag=$3
RewriteRule /all_([a-z]+)_auctions_([0-9]+)_([a-zA-Z]).*\.html$ /allauctions\.php\?aid=$2&hashtag=$3
RewriteRule /all_([a-z]+)_auctions_([0-9]+)_([0-9]+).*\.html$ /allauctions\.php\?aid=$2&pgno=$3
RewriteRule /all_([a-z]+)_auctions_([0-9]+).*\.html$ /allauctions\.php\?aid=$2
RewriteRule /bid_history_([0-9]+)_N.*\.html$ /bid_history\.php\?pgNo=$1
RewriteRule /([a-zA-Z_]+)_([0-9]+).*\.html$ /$1\.php\?pgno=$2
RewriteRule /(.*)\.html$ /$1\.php [I]

7. 如果IIS网站 已经配置了ISAPI筛选器, 其实也可以用. 那么每一个站点的 httpd.ini 就是放在站点的根目录下面, 如果不能显示正常,则是httpd.ini 规则的写法问题
补充:

由于我是先删了网站的 ISAPI筛选器,配置了独立站点的 ISAPI筛选器,现在想恢复网站(所有站点都有效)的ISAPI筛选器, 添加之后发现加载不成功, 其实这个需要重启 IIS.
如果站点也配了ISAPI筛选器那么,站点的起作用, httpd.ini 是同站点配的ISAPI筛选器 的ISAPI_Rewrite.dll 同一个目录下的 httpd.ini 生效,而不是站点根目录的 httpd.ini 起作用.

注意:最后可能需要重启IIS服务器,检查一下ISAPI过滤器中Rewrite是否已经载入——绿色的向上箭头。另外,如果是NTFS文件系统,ISAPI_Rewrite的安装目录需要添加网站用户或everyone的写权
posted on 2011-03-08 04:12  刺猬的温驯  阅读(548)  评论(0编辑  收藏  举报