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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With