我试着这样做:

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Redirect to https" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                        <add input="{REQUEST_URI}" negate="true" pattern="^/robots\.txt$" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

但它没有用......我做错了什么?

最佳答案

您的规则是正确的,很可能是您的浏览器缓存了 301 重定向。能否请您清除浏览器的缓存并尝试访问 robots.txt

关于使用 web.config 重定向排除 robots.txt,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46976603/

10-13 01:59