[英]IIS URL Rewrite with multiple domains
我创建了一个新的 iis 网站,其中主要的 url 是例如: www.test.com
我为我的产品页面创建了这个规则:
<rule name="products" enabled="true" stopProcessing="true" >
<match url="^fr/products/([_0-9a-z-]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="product.aspx?lan={R:0}&cod={R:1}&lib={R:2}" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|svg|jpeg|js|flv|f4v)$" negate="true" />
</conditions>
</rule>
这个 url http://www.test.com/fr/products/5858/tomato工作正常。
但现在它想使用不同的域扩展名:
http://www.test.fr/products/5858/tomtato
In my DNS http://www.test.com and http://www.test.fr goes on the same ip.
我如何使用重写规则来管理它?
要匹配 iis URL 重写规则中的域名,您可以使用服务器变量 {HTTP_HOST}。
<rule name="products" enabled="true" stopProcessing="true">
<match url="^fr/products/([_0-9a-z-]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="product.aspx?lan={R:0}&cod={R:1}&lib={R:2}" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|svg|jpeg|js|flv|f4v)$" negate="true" />
<add input="{HTTP_HOST}" pattern="^www.test.com$" />
</conditions>
</rule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.