Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

http to https rewrite too many redirect loops IIS 7

Tags:

I have application which I have hosted in IIS 7.0. Where I have to make sure that it works only on HTTPS and not on HTTP so I have included below rule in my root config.

<rewrite>         <rules>             <rule name="HTTP to HTTPS redirect" stopProcessing="true">               <match url="(.*)" />               <conditions>                 <add input="{HTTPS}" pattern="off" />               </conditions>               <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}"   redirectType="Found" />             </rule>         </rules> </rewrite>  

After adding this rule when i tried to access my application I get below error:

Page has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer. Here are some suggestions: Reload this web page later. Learn more about this problem.

like image 888
Prashant Mohite Avatar asked Sep 11 '15 12:09

Prashant Mohite


People also ask

What causes too many redirects?

The reason you see the “too many redirects” error is because your website has been set up in a way that keeps redirecting it between different web addresses. When your browser tries to load your site, it goes back and forth between those web addresses in a way that will never complete — a redirect loop.


1 Answers

Put below input condition:

<add input="{HTTPS}" pattern="on" />  

Instead of:

<add input="{HTTPS}" pattern="off" /> 
like image 188
Gparmar Avatar answered Oct 27 '22 01:10

Gparmar