web.config中用于将HTTPS请求重定向到HTTP的IIS重写规则

web.config中用于将HTTPS请求重定向到HTTP的IIS重写规则,iis,url-rewriting,web-config,Iis,Url Rewriting,Web Config,我需要将所有https请求重定向到http,例如,如果有人访问 我现在在web.config中有以下重写规则,但它不能正常工作。它将重定向到,因此重定向到站点的根目录,但我希望重定向保持在同一URL中,并且只将https重写为http <rule name="Redirect to HTTP" stopProcessing="true"> <match url="(.*)" /> <conditions> <add inp

我需要将所有https请求重定向到http,例如,如果有人访问

我现在在web.config中有以下重写规则,但它不能正常工作。它将重定向到,因此重定向到站点的根目录,但我希望重定向保持在同一URL中,并且只将https重写为http

 <rule name="Redirect to HTTP" stopProcessing="true">
   <match url="(.*)" />
     <conditions>
       <add input="{R:1}" pattern="^onepage/(.*)$" negate="true" />
       <add input="{HTTPS}" pattern="^ON$" />
     </conditions>
     <action type="Redirect" url="http://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
 </rule>


任何关于更改上述规则的帮助,使其仅将https更改为http,但保持完整的url访问将不胜感激

请将下面的代码粘贴到
web.config
文件中

<rule name="Redirect to http" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP}" pattern="off" ignoreCase="true" />
    </conditions>
    <action type="Redirect" url="http://{HTTPS_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>

我建立了你的规则,清理了一点,它起了作用;所以这并不是什么新鲜事

建议:删除只用于测试的
onepage
输入条件,正如cheesmacfly在问题注释中所建议的那样

另外,尝试将操作更改为
{R:1}
,而不是
{R:0}
。在这种情况下,这不重要,但我喜欢使用1和以上,以匹配特定的捕获组。R:0表示整个匹配的字符串,这总是让我有点困惑

<rule name="Redirect to HTTP" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTPS}" pattern="^ON$" />
    </conditions>
    <action type="Redirect" url="http://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>


什么是
?非常相关,尽管这个问题在技术上不是一个重复:谢谢,但正如问题中所述,站点运行的是IIS而不是Apache,所以没有.htaccess文件。相反,我使用的是一个web.config文件和IIS重写模块。我认为您键入了错误的HTTP和HTTPS。它们必须颠倒过来