I have a problem. On IIS
I got a web-site with two ports 80
and 443(https)
. I want to redirect all the http
requests from user to https
. I also added Rewrite rule to https
, but when I enter in browser http://localhost/site
it gives me the same page. I need to redirect user to httpS://localhost/site
.
Maybe this is because of my local configurations?
And I disable Require SSL
on IIS
.
The rule is:
<rewrite>
<rules>
<rule name="HTTPS Redirect">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="false" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
</rules>
</rewrite>
Thank you.
Below is the exact rule we use on a production IIS 7 site to redirect all request from HTTP to HTTPS
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
There are some minor differences between what you have posted and what we use. Also, since you are running on local host, you wouldn't be using the built-in web server with visual studio would you? I don't think it will process IIS rewrite rules.
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