PHP   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php – 如何对web.config文件中的某些文件强制使用http大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一些文件需要在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应用程序

解决方法

您需要将规则更改为:
<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.php或page2.php开头的任何url.该操作将请求重定向到https:// {HTTP_HOST} / {R:0},其中{R:0}包含所请求的路径.

大佬总结

以上是大佬教程为你收集整理的php – 如何对web.config文件中的某些文件强制使用http全部内容,希望文章能够帮你解决php – 如何对web.config文件中的某些文件强制使用http所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: