localhost:5011 is url and localhost:44330 is SSL url. I want to redirect http://localhost:5011 to https://localhost:44330 in my web.config. I found rule for this but it is not worked as I wanted:
<rule name="Redirect local requests to https" stopProcessing="true">
<match url="(localhost:5011*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://localhost:44330/" redirectType="Permanent" appendQueryString="true" />
</rule>
This redirects to https://localhost:5011. How can I fix this?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I think your rul won’t redirect Because<match url= ? doesn’t contain hostname and port number.
If you need to redirect http://localhost:5011 to https://localhost:44330, please try this rule
<rule name="Redirect local requests to https" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="localhost" />
<add input="{SERVER_PORT}" pattern="^5011$" />
</conditions>
<action type="Redirect" url="https://localhost:44330/" redirectType="Permanent" appendQueryString="true" />
</rule>
IIs shouldn’t redirect http://localhost:5011 to https://localhost:5011, so please check whether you have other rewrite rule or your application is doing the same work.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0