Iis azure web应用程序:www到非www https

Iis azure web应用程序:www到非www https,iis,web-config,azure-web-app-service,iis-8,Iis,Web Config,Azure Web App Service,Iis 8,我有一个Azure web应用程序,需要帮助执行https 到 到 www.example.com至 example.com至 当前的web.config如下所示。这不适用于-> 您可以使用两个单独的规则来完成此操作。在web.config文件中设置以下配置 <rewrite> <rules> <rule name="HTTP Redirect to HTTPS" enabled="true" stopProcessing="true">

我有一个Azure web应用程序,需要帮助执行https

www.example.com至

example.com至

当前的web.config如下所示。这不适用于->


您可以使用两个单独的规则来完成此操作。在web.config文件中设置以下配置

<rewrite>
    <rules>
        <rule name="HTTP Redirect to HTTPS" enabled="true" stopProcessing="true">
            <match url="(.*)" ignoreCase="false" />
            <conditions>
                <add input="{HTTPS}" pattern="off" />
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>

    <rewrite>
    <rules>
        <rule name="Redirects to www.domain.com" patternSyntax="ECMAScript" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny">
                <add input="{HTTP_HOST}" pattern="^domain.com$" />
            </conditions>
            <action type="Redirect" url="https://example.com/{R:0}" />
        </rule>
    </rules>

</rewrite>


希望这有帮助。

根据您的url重写规则,我假设您的规则没有问题。虽然我没有配置自定义域,但我只是在我的azure web应用程序上测试它,它只包含一些静态html文件和web.config文件,然后我强制它从
bruce webapp.azurewebsites.net
重定向到
https://azurewebsites.net
如下所示:



收集网络跟踪以解决此问题。此外,您可以使用更多详细信息(fiddler网络跟踪或您通过浏览器浏览时发生了什么情况)更新您的问题,以便我们查找此问题。

这不适用于https://www.example.com“to https://example.com”谢谢您的回答,现在,我已切换到www格式。
<rewrite>
    <rules>
        <rule name="HTTP Redirect to HTTPS" enabled="true" stopProcessing="true">
            <match url="(.*)" ignoreCase="false" />
            <conditions>
                <add input="{HTTPS}" pattern="off" />
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>

    <rewrite>
    <rules>
        <rule name="Redirects to www.domain.com" patternSyntax="ECMAScript" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny">
                <add input="{HTTP_HOST}" pattern="^domain.com$" />
            </conditions>
            <action type="Redirect" url="https://example.com/{R:0}" />
        </rule>
    </rules>

</rewrite>