doutang1884 2013-02-13 10:08
浏览 51
已采纳

如何对web.config文件中的某些文件强制使用http

I have some files which needs to be in http .I tried the following code but doesn't work. How can I set force HTTP for the pages page1,page2 in web.config

<?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>

Iam working in IIS 7 web server for PHP application in windows

  • 写回答

1条回答 默认 最新

  • douqiang4501 2013-02-13 16:50
    关注

    You need to change your rule to:

    <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>  
    

    The url="^page[12].php(.*)" will match any url starting with page1.php or page2.php.
    The action redirects the request to https://{HTTP_HOST}/{R:0} where {R:0} contains the requested path.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题