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论坛+UCHome Rewrite规则

# 此默认规则只针对UCHome程序放在根目录中用独立域名访问的,论坛也可以直接用.
RewriteRule ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)\?*(.*)$ $1/archiver/index\.php\?$2&$4
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html\?*(.*)$ $1/forumdisplay\.php\?fid=$2&page=$3&$4
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html\?*(.*)$ $1/viewthread\.php\?tid=$2&extra=page\%3D$4&page=$3&$4
RewriteRule ^(.*)/space-(username|uid)-(.+)\.html\?*(.*)$ $1/space\.php\?$2=$3&$4
RewriteRule ^(.*)/tag-(.+)\.html\?*(.*)$ $1/tag\.php\?name=$2&$3
#uch放在根目录时的伪静态
RewriteRule ^/(space|network)-(.+)\.html$ /$1\.php\?rewrite=$2 [L]
RewriteRule ^/(space|network)\.html$ /$1\.php [L]
RewriteRule ^/([0-9]+)$ /space\.php\?uid=$1 [L]
#uch放在二级目录时的伪静态
RewriteRule ^/uhome/(space|network)-(.+)\.html$ /uhome/$1\.php\?rewrite=$2 [L]
RewriteRule ^/uhome/(space|network)\.html$ /uhome/$1\.php [L]
RewriteRule ^/uhome/([0-9]+)$ /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]+)\.xml /feed\.php\?cat=$1
RewriteRule /feed-b([0-9]+)\.xml /feed\.php\?brand=$1
RewriteRule /feed\.xml$                 feed\.php
RewriteRule /category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.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]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html /category\.php\?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5
RewriteRule /category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html /category\.php\?id=$1&brand=$2&page=$3&sort=$4&order=$5
RewriteRule /category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html /category\.php\?id=$1&brand=$2&page=$3
RewriteRule /category-([0-9]+)-b([0-9]+)(.*)\.html /category\.php\?id=$1&brand=$2
RewriteRule /category-([0-9]+)(.*)\.html /category\.php\?id=$1
RewriteRule /goods-([0-9]+)(.*)\.html /goods\.php\?id=$1
RewriteRule /article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html /article_cat\.php\?id=$1&page=$2&sort=$3&order=$4
RewriteRule /article_cat-([0-9]+)-([0-9]+)(.*)\.html /article_cat\.php\?id=$1&page=$2
RewriteRule /article_cat-([0-9]+)(.*)\.html /article_cat\.php\?id=$1
RewriteRule /article-([0-9]+)(.*)\.html /article\.php\?id=$1
RewriteRule /brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html /brand\.php\?id=$1&cat=$2&page=$3&sort=$4&order=$5
RewriteRule /brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html /brand\.php\?id=$1&cat=$2&page=$3
RewriteRule /brand-([0-9]+)-c([0-9]+)(.*)\.html /brand\.php\?id=$1&cat=$2
RewriteRule /brand-([0-9]+)(.*)\.html /brand\.php\?id=$1
RewriteRule /tag-(.*)\.html /search\.php\?keywords=$1
RewriteRule /snatch-([0-9]+)\.html /snatch\.php\?id=$1
RewriteRule /group_buy-([0-9]+)\.html /group_buy\.php\?act=view&id=$1
RewriteRule /auction-([0-9]+)\.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_(.+)\.html\?*(.*)$ $1/shop/tag\.php\?tagname=$2 [L]
#商铺大全
RewriteRule ^(.*)/shop/cate_([0-9]+)\.html\?*(.*)$ $1/shop/cate\.php\?cd=$2 [L]
RewriteRule ^(.*)/cate_([0-9]+)_([a-z]+)_([0-9]+)\.html\?*(.*)$ $1/shop/cate\.php\?cd=$2&order=$3&page=$4 [L]
#RewriteRule ^shop/cate_([0-9]+)(\.html|) shop/cate.php?cd=$1
#RewriteRule ^shop/cate_([0-9]+)_([a-z]+)_([0-9]+)(\.html|) shop/cate.php?cd=$1&order=$2&page=$3
#商铺页面
RewriteRule ^(.*)/shop/([0-9]+)\?*(.*)$ $1/shop/shop\.php\?shopid=$2$3 [L]
#RewriteRule ^shop/(shop_|)([0-9]+)(\.html|)$ shop/shop.php?shopid=$2$3
#点评内容页面
RewriteRule ^(.*)/shop/viewreview_([0-9]+)\.html\?*(.*)$ $1/shop/viewreview\.php\?reviewid=$2 [L]
RewriteRule ^(.*)/shop/viewreview_([0-9]+)\.html#respond$\?*(.*)$ $1/shop/viewreview.php?reviewid=$2#respond [L]
#个人空间
RewriteRule ^(.*)/space/([0-9]+)$ $1/space/index\.php\?suid=$2 [L]
RewriteRule ^(.*)/space/([0-9]+)_([a-z]+)\?*(.*)$ $1/space/index\.php\?suid=$2&n=$3 [L]
#兑奖中心
RewriteRule ^(.*)/exchange/gift_([0-9]+)\.html\?*(.*)$ $1/exchange/index\.php\?action=gift&giftid=$2 [L]
#优惠券,这个有问题,不用
#RewriteRule ^(.*)/coupon/([0-9]+)\?*(.*)$ $1/coupon/index\.php\?ac=detail&couponid=$2$3 [L]
#新闻资讯
RewriteRule ^(.*)/article/([0-9]+)\.html\?*(.*)$ $1/article/article\.php\?articleid=$2 [L]
RewriteRule ^(.*)/article/classid_([0-9]+)\.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]+)_(.*)\.html$ $1/index\.php\?app=$2&arg=$3 [I]

三、特别说明

1、刚开装好ISAPI_Rewrite,全局重写正常而独立站点重写失败的解决办法:在需要使用rewrite的站点根目录下创建httpd.ini文件,并且给相应用户的读权限

并且一定要以以下语句开头
[ISAPI_Rewrite]

RewriteCond Host: www\.1100do\.cn (此处网址改成你的网址)

文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: 678
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 20 字 | UBB代码 关闭 | [img]标签 关闭