前提你要自己有服务器, 然后下载:http://www.helicontech.com/download.asp 接着安装,随便装哪都行。 然后,打开Internet 信息服务,右键,web站点属性,点ISAPI筛选器选项卡.添加筛选器,名称填个rewrite,路径自己指定ISAPI_Rewrite.dll(在安装的根目录下),然后确定. 设置扩展: 右击我的电脑--管理--服务与应用程序--Internet信息服务(IIS)管理--Web服务扩展--添加一个新的Web服务扩展--输入扩展名:ISAPI_Rewrite--添加--浏览--找到你的安装目录选中ISAPI_Rewrite.dll打开并设置为允许运行此扩展 最后.. 开始添加rewrite规则.正则,找到ISAPI_Rewrite目录,把httpd.ini的只读属性去掉,打开编辑. 打开时的内容是: [ISAPI_Rewrite] # Defend your computer from some worm attacks RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O] 我们在[ISAPI_Rewrite]下添加以下内容然后保存即可: [ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 # Protect httpd.ini and httpd.parse.errors files # from accessing through HTTP RewriteRule ^(.*)/archiver/([a-z0-9\-]+\.html)$ $1/archiver/index\.php\?$2 RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay\.php\?fid=$2&page=$3 RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$$1/viewthread\.php\?tid=$2&extra=page\%3D$4&page=$3 RewriteRule ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro\.php\?$2=$3 我的成功设置内容如下: [Copy to clipboard] [ - ] CODE: [ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 # Protect httpd.ini and httpd.parse.errors files # from accessing through HTTP RewriteRule ^(.*)/archiver/([a-z0-9\-]+\.html)$ $1/archiver/index\.php\?$2 RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay\.php\?fid=$2&page=$3 RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$$1/viewthread\.php\?tid=$2&extra=page\%3D$4&page=$3 RewriteRule ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro\.php\?$2=$3 # Defend your computer from some worm attacks RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O] 然后提交就算是全部完成了,回到论坛看看是否你的论坛已经有静态页面,有了吧,开心吧,我也是完成后好开心。 利用isapi_rewrite防盗链 利用isapi_rewrite可以实现类似于Apache的伪静态路径,利用其检查refer的功能我们还可以实现防盗链。该软件可以在 http://www.helicontech.com/download/下载,是一个共享软件,但是有一个LITE版本是免费的,基本上可以实现我们需要的功能。安装的步骤我就不详细说了,具体说说httpd.ini的设置。 首先,必须要保证httpd.ini有可写权限,设置isapi_rewrite安装文件夹everyone具有可修改权限后,去除该文件的只读属性。 httpd.ini默认设置如下: RewriteCond Host: (.+) RewriteCond Referer: (?!http://\1.*).* 我们在它后面加上一句 RewriteRule .*\.(?:gif|jpg|png|exe|rar|zip) /block.gif [I,O] 即可实现gif/jpg/png/exe/rar/zip文件的防盗链,盗链页面显示的是/block.gif。block.gif是一个体积较少的图片文件,我们可以在上面打上自己网站的版权标志和防盗链声明。 如果按照上面设置,则除本站以外的所有网站均不能使用这里的图片,如果要允许一些例外的网站比如google,baidu以及其它一些非营利性网站引用该怎么办呢?我们可以用如下正则表达式来实现 RewriteCond Referer: (?!http://(?:www\.0e2\.net|www\.google\.com|www\.baidu\.com)).+ 如果想允许所有google子站和baidu子站形如images.baidu.com,images.google.com等站则做如下设置: RewriteCond Referer: (?!http://(?:*\.0e2\.net|*\.google\.com|*\.baidu\.com)).+ 至此,一个相当有效的防盗链系统已经出来了,但如上设置有一个问题,如果浏览者浏览了盗链页面后访问本站页面,则被盗链图片的缓存会影响图片的正常显示。把 RewriteRule .*\.(?:gif|jpg|png|exe|rar|zip) /block.gif [I,O] 改为 RewriteRule .*\.(?:gif|jpg|png|exe|rar|zip) /block.gif [I,O,N] 方可。参数N的意思是重新从站点请求文件而不是从本地缓存读取。
