Aug
16

万网G享主机URL重写

应工作需求,需要在万网G享主机上做URL重写。

1, 首先万网问题帮助中心有手册 (实为装字母二,误导人的,只有最基本的介绍,根本满足不了需求。其实就是iis7的URL Rewrite Module 2.0) 见: http://learn.iis.net/page.aspx/665/url-rewrite-module-20-configuration-reference/

2. 配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rule1" stopProcessing="true">
<match url="^$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^cn.xxx.com$" />
</conditions>
<action type="Rewrite" url="/newweb/cn/index.asp" />
</rule>

<rule name="rule2" stopProcessing="true">
<match url="(.+)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^cn.xxx.com$" />
</conditions>
<action type="Rewrite" url="/newweb/cn/{R:1}" />
</rule>

</rules>
</rewrite>
</system.webServer>
</configuration>

注: conditions增加约束条件。

<match url="(.+)" />

中url不带域名和端口。如 http://cn.xxx.com:82/bb/a.asp,url中为 bb/a.asp

另,ilterByTags过滤

<outboundRules>
          <rule name="Add application prefix">
            <match filterByTags="A,Img,Script,Link" pattern="^/(.*)" />
            <conditions>
              <add input="{URL}" pattern="^/leven/.*" />
            </conditions>
            <action type="Rewrite" value="/leven/{R:1}" />
          </rule>
        </outboundRules>

共计 0 条评论

NAME:

required

E-MAIL:

required, will not be published

HOMEPAGE:

CONTENT: