Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 678
suneesh Avatar asked Oct 22 '22 17:10

suneesh


1 Answers

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.

like image 192
cheesemacfly Avatar answered Oct 31 '22 17:10

cheesemacfly