隐藏

IIS8.5中的强制https直接修改web.config文件和顶级域名跳转www和过滤子目录不强制跳转

发布:2021/9/26 17:21:24作者:管理员 来源:本站 浏览次数:821

亲测可用

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="没有加www的自动重定向到加www的域名下301Redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{HTTP_HOST}" pattern="^zybw.com$" />
                    </conditions>
                    <action type="Redirect" url="https://www.zybw.com/{R:0}" redirectType="Permanent" />
                </rule>
                <rule name="HTTP to HTTPS redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>