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

时间:2014-03-26 03:03:37

标签: asp.net redirect web-config

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

以下是我的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>

1 个答案:

答案 0 :(得分:0)

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

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

http://forums.iis.net/t/1206943.aspx?HTTPS+to+HTTP+redirect+in+web+config