IISredirect到www

我正在使用IIS 7来托pipe一个Web应用程序。 目前,我在web.config中有一条规则,将所有stream量redirect到HTTPS,但是它不会自动将stream量redirect到www,这对于某些function很重要。 web.config显示如下:

<rewrite> <rules> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> <add input="{URL}" pattern="seek\.svc$" ignoreCase="true" negate="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> 

任何人都可以告诉我如何将所有请求redirect到www? 使用此路线或使用IIS GUI。

我已经find了这个: IIS 6 – build立301redirect非www到wwwsearch引擎优化

哪个技巧,但创build一个重复的网站似乎有点混乱给我。 还有其他build议吗?

谢谢

在现有的规则集之前创build第二个规则集,不带stopProcessing标志,并添加一个与www.匹配的条件www. 在任何其他事情之前,将否定标志设置为true,如下所示:

 <add input="{HTTP_HOST}" pattern="^www\.([.a-zA-Z0-9]+)$" negate="true" /> 

然后添加www. 到这样的行动的url:

 <action type="Redirect" redirectType="Found" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" />