如何在 IIS 托管网站上强制执行 www?
How do I enforce www on an IIS hosted website?
我的站点托管在 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}
将包含协议,{C:2}
将包含您的域和其他任何内容。
(source)
我的站点托管在 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}
将包含协议,{C:2}
将包含您的域和其他任何内容。
(source)