Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Whole site is redirected to https but I need some pages to redirected to http, is this possible with web.config?

I need following pages (packages.php and hotelonly.php) to redirect to http, as all my other pages are automatically redirected to https.

I am trying to achive this with following code but it will not work.

HTML
  <rewrite>
   <rules>
    <rule name="Canonical Host Name" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^domain\.com$" />
      </conditions>
      <action type="Redirect" url="https://www.domain.com{R:1}" redirectType="Permanent" />
    </rule>
    <rule name="Force HTTPS" stopProcessing="true">
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAll">
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        <add input="{REQUEST_URI}" negate="true" pattern="^(packages|hotelonly)\.php$" ignoreCase="true" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>


What I have tried:

I have tried the code above but it will not work.
Posted
Comments
Richard Deeming 1-Sep-16 9:27am    
Why? If you're serving parts of your site over HTTPS, you might as well serve the whole thing over HTTPS.
Member 12714999 1-Sep-16 11:39am    
I have external iframe links embedded on these pages and the iframe links will only work with http, and they do not work if my pages were https and iframe links http.
Member 12714999 3-Sep-16 14:31pm    
<add input="{REQUEST_URI}" negate="true" pattern="^(packages|hotelonly)\.php$" ignorecase="true"> This works fine but the problem is that I have iframe embedded in these pages and it adds further details and changes URL. Is there any way of excluding it if packages.php and hotelonly.php mentioned in the URL? When iframe runs, URLs dynamically changes like packages.php?type=1&aff=4&... or hotelonly.php?type=2&aff=4&.... etc. depending on user selection.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900