通过web.config进行ASP.net重定向

通过web.config进行ASP.net重定向,asp.net,redirect,web-config,Asp.net,Redirect,Web Config,我是ASP.net的新手,我正在尝试将“联系我们”页面重定向到https。其余的应该使用http。在某种程度上,我能够做到这一点。我的问题是,当我从“联系我们”页面单击“主页”时,它不会返回到http。。它仍然是https。其他链接都很好 下面是my web.config的部分内容。我希望有人能帮助我。谢谢 <rewrite> <rules> <rule name="root to http" patternSyntax="Wildcard" stopProces

我是ASP.net的新手,我正在尝试将“联系我们”页面重定向到https。其余的应该使用http。在某种程度上,我能够做到这一点。我的问题是,当我从“联系我们”页面单击“主页”时,它不会返回到http。。它仍然是https。其他链接都很好

下面是my web.config的部分内容。我希望有人能帮助我。谢谢

<rewrite>
<rules>

<rule name="root to http" patternSyntax="Wildcard" stopProcessing="true">
<match url="https://www.bpicards.com/" />
<action type="Redirect" url="http://www.bpicards.com/" redirectType="Permanent" />
</rule>

<rule name="Redirect non-www to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="bpicards.com" />
</conditions>
<action type="Redirect" url="http://www.bpicards.com/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Cards-Details-54-slash" patternSyntax="Wildcard" stopProcessing="true">
<match url="Cards/Details/54/" />
<action type="Redirect" url="/Cards/" redirectType="Permanent" />
</rule>
<rule name="Cards-Details-54" patternSyntax="Wildcard" stopProcessing="true">
<match url="Cards/Details/54" />
<action type="Redirect" url="/Cards/" redirectType="Permanent" />
</rule>
<rule name="RealThrills-ItemDetails-155" patternSyntax="Wildcard" stopProcessing="true">
<match url="RealThrills/ItemDetails/155" />
<action type="Redirect" url="/RealThrills/" redirectType="Permanent" />
</rule>
<rule name="Contact Us" patternSyntax="Wildcard" stopProcessing="true">
<match url="ContactUs" />
<action type="Redirect" url="https://www.bpicards.com/ContactUs/" redirectType="Permanent" />
</rule>



<rule name="Cards" patternSyntax="Wildcard" stopProcessing="true">
<match url="Cards" />
<action type="Redirect" url="http://www.bpicards.com/Cards/" redirectType="Permanent" />
</rule>


<rule name="Real Thrills" patternSyntax="Wildcard" stopProcessing="true">
<match url="RealThrills" />
<action type="Redirect" url="http://www.bpicards.com/RealThrills/" redirectType="Permanent" />
</rule>


<rule name="BPI Buys" patternSyntax="Wildcard" stopProcessing="true">
<match url="BpiBuys" />
<action type="Redirect" url="http://www.bpicards.com/Bpibuys/" redirectType="Permanent" />
</rule>


<rule name="Sip" patternSyntax="Wildcard" stopProcessing="true">
<match url="Sip" />
<action type="Redirect" url="http://www.bpicards.com/Sip/" redirectType="Permanent" />
</rule>


<rule name="Calculators" patternSyntax="Wildcard" stopProcessing="true">
<match url="Calculators" />
<action type="Redirect" url="http://www.bpicards.com/Calculators/" redirectType="Permanent" />
</rule>


<rule name="ApplyNow" patternSyntax="Wildcard" stopProcessing="true">
<match url="ApplyNow" />
<action type="Redirect" url="http://www.bpicards.com/ApplyNow/" redirectType="Permanent" />
</rule>


<rule name="BPI Cards" patternSyntax="Wildcard" stopProcessing="true">
<match url="BpiCards" />
<action type="Redirect" url="http://www.bpicards.com/BpiCards/" redirectType="Permanent" />
</rule>



</rules>
</rewrite>

您需要为IIS7安装并启用URL重写模块,并在web.config文件中使用重定向规则

您可能需要检查此链接以获取一些示例代码