如何在IIS托管的网站上执行www?
问题描述:
我的网站托管在IIS上,我需要强制浏览器使用www前缀。如何在IIS托管的网站上执行www?
我已经安装了Url Rewrite Module,我的原则是:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Add WWW" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www\.)(.*)$" />
</conditions>
<action type="Redirect" url="http://www.{C:0}{PATH_INFO}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
从IIS7 URL Rewrite - Add "www" prefix
但我不能工作,如何维持SSL
答
您需要捕获的协议在输入:
<rule name="Enforce WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{CACHE_URL}" pattern="^(.+)://(?!www)(.*)" />
</conditions>
<action type="Redirect" url="{C:1}://www.{C:2}" redirectType="Permanent" />
</rule>
{C:1}
will co ntain协议和{C:2}
将有你的域名和其他任何东西。
(source)
欢迎计算器,请考虑[接受](http://*.com/help/accepted-answer)的答案,或者提供一些反馈,如果我误解你的方案或只是普通的错了:-) – NikolaiDante