设为首页 收藏本站
查看: 802|回复: 0

[经验分享] IIS isapi_rewrite 重写

[复制链接]

尚未签到

发表于 2015-11-15 09:26:34 | 显示全部楼层 |阅读模式
  ISAPI_Rewrite有Full和Lite两个版本。Full是商业版,Lite是免费版。
经过反复测试,发现Lite版只读取安装目录下的httpd.ini文件,而不会读取每个网站根目录下的httpd.ini。
只有Full版才会读取网站根目录下的httpd.ini配置。
刚才到官网上仔细查了Lite版的介绍,才发现原来官网上早已说明,只是我以前没有发现而已。
为了方便其他朋友区分Lite版和Full版,我把Lite版的简介翻译写在下面:
原文翻译Lite version of ISAPI_Rewrite shares the same rewrite engine and features but with the following limitations:ISAPI_Rewrite的Lite版本使用(与Full版本)
相同的rewrite引擎和属性,但是有以下几点限制:No support for distributed .htaccess configurations, directory and web site level configurations. Only one global httpd.conf configuration file will be loaded from Lite version installation folder.
不支持分布式的.htaccess配置、目录和站点级
配置。只有Lite版安装目录下的公用的httpd.conf
(httpd.ini)配置文件会被读取。No support for <VirtualHost>, <Directory>, <DirectoryMatch>, <Files>, <FilesMatch>, <Location> and <LocationMatch> tags.
不支持<VirtualHost>、<Directory>、<DirectoryMatch>
、<Files>、<FilesMatch>、<Location> 和<LocationMatch>标签.There is no proxy module in Lite version, thus all proxy related functions like RewriteProxy directive and [P] flag will be ignored.
Lite版本中不包含代理模块,所以所有与代理有
关的函数例如RewriteProxy指令和[P]标签都将无效。No manual installation package for Lite version to install in a shared hosting environment.
没有为Lite版安装在共享主机环境中的文档安装包
(这条看不太懂,翻译的可能不对)ISAPI_Rewrite Lite is completely free and it is a good solution for development or testing purposes and for small servers that host only a few web sites and don’t require distributed configurations or proxy functions.ISAPI_Rewrite Lite是完全免费的。如果只是以开发
或测试为目的,或者是一台仅有少量网站不需要分布配置
和代理功能的服务器,它将是一个很好的解决方案。  Rewrite规则相冲突解决办法 IIS isapi_rewrite full多站点配置方法
  一、首先安装ISAPI_Rewrite (可以到网上找一个破解版或者购买一个正版,本文以isapi_rwf_0053.msi为例)
  1、双击安装isapi_rwf_0053.msi 一路点击NEXT 直至完成;
  2、安装完成后打开ISAPI_Rewrite目录中ISRWConfig.exe,输入注册码完成注册(如果是破解版的则无需这一步)。
  3、安装完成后,如不能正常运行,请照以下说明设置ISAPI_Rewrite目录权限
  Administrators 和 SYSTEM 全部权限
  IIS_WPG   读取和运行/读取
  单独对ISAPI_Rewrite/ISAPI_Rewrite.dll设权限,加入Everyone的访问”读取”权限。
  打开IIS管理器,点击左边网站,右键-属性-ISAPI筛选器-然后定位到ISAPI_Rewrite\ISAPI_Rewrite.dll确定启用,然后重启IIS生效。
  通过上面的安装与设置后,rewrite已经可以使用了。
  二、多站点的配置方法
  如果你在一台服务器上安装了多个网站,而且都希望实现伪静态,那可以采用全局的方式配置,全局配置方式跟ISAPI_Rewrite免费版是一样的,即把规则全部写到安装目录下的httpd.ini(有些版本为httpd.conf)中,重启iis即可;这里主要说一下全局配置结合独立配置的方法:
  1、对于不会影响到其它网站正常运行的规则,可以考虑写到全局设置里。
  # 以下是DZ6.0/6.1/7.0论坛&#43;UCHome Rewrite规则
  # 此默认规则只针对UCHome程序放在根目录中用独立域名访问的,论坛也可以直接用.
RewriteRule ^(.*)/archiver/((fid|tid)-[\w\-]&#43;\.html)\?*(.*)$ $1/archiver/index\.php\?$2&$4
RewriteRule ^(.*)/forum-([0-9]&#43;)-([0-9]&#43;)\.html\?*(.*)$ $1/forumdisplay\.php\?fid=$2&page=$3&$4
RewriteRule ^(.*)/thread-([0-9]&#43;)-([0-9]&#43;)-([0-9]&#43;)\.html\?*(.*)$ $1/viewthread\.php\?tid=$2&extra=page\%3D$4&page=$3&$4
RewriteRule ^(.*)/space-(username|uid)-(.&#43;)\.html\?*(.*)$ $1/space\.php\?$2=$3&$4
RewriteRule ^(.*)/tag-(.&#43;)\.html\?*(.*)$ $1/tag\.php\?name=$2&$3
#uch放在根目录时的伪静态
RewriteRule ^/(space|network)-(.&#43;)\.html$ /$1\.php\?rewrite=$2 [L]
RewriteRule ^/(space|network)\.html$ /$1\.php [L]
RewriteRule ^/([0-9]&#43;)$ /space\.php\?uid=$1 [L]
#uch放在二级目录时的伪静态
RewriteRule ^/uhome/(space|network)-(.&#43;)\.html$ /uhome/$1\.php\?rewrite=$2 [L]
RewriteRule ^/uhome/(space|network)\.html$ /uhome/$1\.php [L]
RewriteRule ^/uhome/([0-9]&#43;)$ /uhome/space\.php\?uid=$1 [L]
  # 以下是Ecshop重写规则
#RewriteRule ^(.*)/index.html    $1/index.php [I]
#RewriteRule ^(.*)/default.html $1/index.php [I]
# access any object by its numeric identifier
RewriteRule /feed-c([0-9]&#43;)\.xml /feed\.php\?cat=$1
RewriteRule /feed-b([0-9]&#43;)\.xml /feed\.php\?brand=$1
RewriteRule /feed\.xml$                 feed\.php
RewriteRule /category-([0-9]&#43;)-b([0-9]&#43;)-min([0-9]&#43;)-max([0-9]&#43;)-attr([^-]*)-([0-9]&#43;)-(.&#43;)-([a-zA-Z]&#43;)(.*)\.html /category\.php\?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8
RewriteRule /category-([0-9]&#43;)-b([0-9]&#43;)-min([0-9]&#43;)-max([0-9]&#43;)-attr([^-]*)(.*)\.html /category\.php\?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5
RewriteRule /category-([0-9]&#43;)-b([0-9]&#43;)-([0-9]&#43;)-(.&#43;)-([a-zA-Z]&#43;)(.*)\.html /category\.php\?id=$1&brand=$2&page=$3&sort=$4&order=$5
RewriteRule /category-([0-9]&#43;)-b([0-9]&#43;)-([0-9]&#43;)(.*)\.html /category\.php\?id=$1&brand=$2&page=$3
RewriteRule /category-([0-9]&#43;)-b([0-9]&#43;)(.*)\.html /category\.php\?id=$1&brand=$2
RewriteRule /category-([0-9]&#43;)(.*)\.html /category\.php\?id=$1
RewriteRule /goods-([0-9]&#43;)(.*)\.html /goods\.php\?id=$1
RewriteRule /article_cat-([0-9]&#43;)-([0-9]&#43;)-(.&#43;)-([a-zA-Z]&#43;)(.*)\.html /article_cat\.php\?id=$1&page=$2&sort=$3&order=$4
RewriteRule /article_cat-([0-9]&#43;)-([0-9]&#43;)(.*)\.html /article_cat\.php\?id=$1&page=$2
RewriteRule /article_cat-([0-9]&#43;)(.*)\.html /article_cat\.php\?id=$1
RewriteRule /article-([0-9]&#43;)(.*)\.html /article\.php\?id=$1
RewriteRule /brand-([0-9]&#43;)-c([0-9]&#43;)-([0-9]&#43;)-(.&#43;)-([a-zA-Z]&#43;)\.html /brand\.php\?id=$1&cat=$2&page=$3&sort=$4&order=$5
RewriteRule /brand-([0-9]&#43;)-c([0-9]&#43;)-([0-9]&#43;)(.*)\.html /brand\.php\?id=$1&cat=$2&page=$3
RewriteRule /brand-([0-9]&#43;)-c([0-9]&#43;)(.*)\.html /brand\.php\?id=$1&cat=$2
RewriteRule /brand-([0-9]&#43;)(.*)\.html /brand\.php\?id=$1
RewriteRule /tag-(.*)\.html /search\.php\?keywords=$1
RewriteRule /snatch-([0-9]&#43;)\.html /snatch\.php\?id=$1
RewriteRule /group_buy-([0-9]&#43;)\.html /group_buy\.php\?act=view&id=$1
RewriteRule /auction-([0-9]&#43;)\.html /auction\.php\?act=view&id=$1
#以下是modoer伪静态规则for1.1
#首页去除首页规则,不然会引起其它子站出错
#RewriteRule ^(.*)/index\.html\?*(.*)$ $1/index\.php [L]
#TAG标签页
RewriteRule ^(.*)/shop/tag\.html\?*(.*)$ $1/shop/tag\.php [L]
RewriteRule ^(.*)/shop/tag_(.&#43;)\.html\?*(.*)$ $1/shop/tag\.php\?tagname=$2 [L]
#商铺大全
RewriteRule ^(.*)/shop/cate_([0-9]&#43;)\.html\?*(.*)$ $1/shop/cate\.php\?cd=$2 [L]
RewriteRule ^(.*)/cate_([0-9]&#43;)_([a-z]&#43;)_([0-9]&#43;)\.html\?*(.*)$ $1/shop/cate\.php\?cd=$2&order=$3&page=$4 [L]
#RewriteRule ^shop/cate_([0-9]&#43;)(\.html|) shop/cate.php?cd=$1
#RewriteRule ^shop/cate_([0-9]&#43;)_([a-z]&#43;)_([0-9]&#43;)(\.html|) shop/cate.php?cd=$1&order=$2&page=$3
#商铺页面
RewriteRule ^(.*)/shop/([0-9]&#43;)\?*(.*)$ $1/shop/shop\.php\?shopid=$2$3 [L]
#RewriteRule ^shop/(shop_|)([0-9]&#43;)(\.html|)$ shop/shop.php?shopid=$2$3
#点评内容页面
RewriteRule ^(.*)/shop/viewreview_([0-9]&#43;)\.html\?*(.*)$ $1/shop/viewreview\.php\?reviewid=$2 [L]
RewriteRule ^(.*)/shop/viewreview_([0-9]&#43;)\.html#respond$\?*(.*)$ $1/shop/viewreview.php?reviewid=$2#respond [L]
#个人空间
RewriteRule ^(.*)/space/([0-9]&#43;)$ $1/space/index\.php\?suid=$2 [L]
RewriteRule ^(.*)/space/([0-9]&#43;)_([a-z]&#43;)\?*(.*)$ $1/space/index\.php\?suid=$2&n=$3 [L]
#兑奖中心
RewriteRule ^(.*)/exchange/gift_([0-9]&#43;)\.html\?*(.*)$ $1/exchange/index\.php\?action=gift&giftid=$2 [L]
#优惠券,这个有问题,不用
#RewriteRule ^(.*)/coupon/([0-9]&#43;)\?*(.*)$ $1/coupon/index\.php\?ac=detail&couponid=$2$3 [L]
#新闻资讯
RewriteRule ^(.*)/article/([0-9]&#43;)\.html\?*(.*)$ $1/article/article\.php\?articleid=$2 [L]
RewriteRule ^(.*)/article/classid_([0-9]&#43;)\.html\?*(.*)$ $1/article/index\.php\?classid=$2 [L]
  —————————————————————————
如果有采用以上几个系统的,可以把以上规则写到全局设置里。
  2、某些站点比较特殊,把它的规则写到全局配置会影响到其它站点的正常运行,那么就要对该站点进行独立配置。例如ecmall的就会导致其它站点出问题。
  # 以下Ecmall重写规则
# 为了确保重写规则不影响服务器上的其他站点
# 请将下面的语句前的#号去掉,并将(?:www\.)?site1\.com改为商店所在域名
RewriteCond %{HTTP:Host} (?:mall\.)?ynczw\.net
RewriteRule ^(.*)/index.html$   $1/index.php [I]
RewriteRule ^(.*)/([a-zA-Z0-9]&#43;)_(.*)\.html$ $1/index\.php\?app=$2&arg=$3 [I]
  三、特别说明
  1、刚开装好ISAPI_Rewrite,全局重写正常而独立站点重写失败的解决办法:在需要使用rewrite的站点根目录下创建httpd.ini文件,并且给相应用户的读权限,添加Everyone访问
  并且一定要以以下语句开头
[ISAPI_Rewrite]
  RewriteCond Host: www\.1100do\.cn (此处网址改成你的网址)
  
  原文地址:http://www.85904.com/post/170.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-139401-1-1.html 上篇帖子: windows2003中IIS对于上传文件大小限制的解决办法 下篇帖子: IIS HTTP 错误 404.17
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表