【问题标题】:How do I do force http for some files in web.config file如何对 web.config 文件中的某些文件强制使用 http
【发布时间】:2013-01-28 20:20:52
【问题描述】:

我有一些文件需要在 http 中。我尝试了以下代码,但不起作用。 如何在 web.config 中为页面 page1、page2 设置强制 HTTP

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
    <rewrite>
        <rules>
            <rule name="Force HTTP" stopProcessing="true">
                <match url="(.*)/page1.php" ignoreCase="false"/>
                                <match url="(.*)/page2.php" ignoreCase="false"/>
                <conditions> 
                    <add input="{HTTPS}" pattern="ON" ignoreCase="true"/>
                </conditions>
                <action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
            </rule>
        </rules>
    </rewrite>
    </system.webServer>
</configuration>

我在 IIS 7 Web 服务器中为 Windows 中的 PHP 应用程序工作

【问题讨论】:

    标签: php asp.net url-rewriting web-config


    【解决方案1】:

    您需要将规则更改为:

    <rule name="Force HTTP" stopProcessing="true">  
      <match url="^page[12].php(.*)" />  
      <conditions>  
        <add input="{HTTPS}" pattern="^ON$" />  
      </conditions>  
      <action type="Redirect" url="http://{HTTP_HOST}/{R:0}" redirectType="Permanent" />  
    </rule>  
    

    url="^page[12].php(.*)" 将匹配任何以page1.phppage2.php 开头的网址。
    该操作将请求重定向到https://{HTTP_HOST}/{R:0},其中{R:0} 包含请求的路径。

    【讨论】:

    • 谢谢...:)。我的意思是不同的页面,例如 (onpage, anher page) 。我将匹配标签更改为 。重定向也是http而不是https。它现在工作正常。再次非常感谢您。
    • @suneesh 是的,重定向到 HTTPS 是一个错字!对不起:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 2011-03-19
    • 2016-02-13
    • 1970-01-01
    相关资源
    最近更新 更多