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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog