我有一些文件需要在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}
包含所请求的路径。