我想把www添加到网站的每个域名中。以下是我希望包括的领域:
到目前为止,我得到的是:
<rule name="Prepend www to 2nd level domain names" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="^([^.]+\.[^.]+)$" />
<add input="{CACHE_URL}" pattern="^(.+)://" />
</conditions>
<action type="Redirect" url="{C:2}://www.{C:1}/{R:0}" />
</rule> 这适用于所有域,但co.in除外。我不知道我怎么能把TLD和不止一个“.”包括进去?
发布于 2015-01-14 16:54:41
你可以用<add input="{HTTP_HOST}" pattern="^domain.*" />
这里有一个更长的版本,它是如何工作的:Forwarding http://mydomain.com/ctrlr/act/val to http://WWW.mydomain.com/ctrlr/act/val
基本上和我上面写的一样。
下面是适合支持TLD的规则
<rule name="Add WWW prefix" >
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.(.*)" />
</conditions>
<action type="Redirect" url="http://www.domain.{C:1}/{R:1}"
redirectType="Permanent" />
</rule>https://stackoverflow.com/questions/27947246
复制相似问题