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.
I realize this may not be your issue, however I had a similar debacle that was cause by a different problem.
I had enabled Require SSL and that caused the site to continually return a 403. So to use this method it appears you must disable SSL Settings -> Require SSL.
Hope this helps someone.
Below is the exact rule we use on a production IIS 7 site to redirect all request from HTTP to HTTPS
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.
Also, if you have more than one rule, order could matter. Be sure to add the redirect rule before other rules or redirect may not fire.
Here is an example that is using SPA that required the rule order.
you can add this to your pages. to force redirection.
I just seen your tag of mvc
add this attribute to your actions. or controllers.