How can I force http for some files in the web.config file

I have files that should be in http. I tried the following code but not working. How to set HTTP strength for 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>

I am working on an IIS 7 web server for a PHP application on Windows

+5
source share
1 answer

You need to change the rule:

<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(.*)"will match any URL starting with page1.phpor page2.php.
The action redirects the request to https://{HTTP_HOST}/{R:0}where it {R:0}contains the requested path.

+3
source

All Articles