Running - IIS 10
- Asp. Net - Web Forms "Web Application" - .NET Framework 4.8
WebAppDemo
is a web forms "application" under "Default Web Site"
Default Web Site
WebAppDemo
Allows only a http:80
binding on default port 80
.
Users use this URL to access this web application like so - http://webappdemo.domain.com/Default.aspx
Now, we want to create a "New Site"
and only allow a https:9443
binding on a custom port :9443
(for example).
This "New Site"
will contain the WebAppDemo
as an application under it
New Site
WebAppDemo
Now, I want the users to keep using the old URL which is http://webappdemo.domain.com/Default.aspx
but be served/redirected to https://webappdemo.domain.com:9443/Default.aspx
Note the https:
and the port # 9443
in the new URL.
How can I achieve this?
Update: 06/08/24
I came up with this rule but the result is not working as expected.
When i browse this URL
using a browser: http://dev-abc-iis.myorg.com/WebAppDemo
I am redirected to this URL :
https://dev-abc-iis.myorg.com/WebAppDemo/
You can notice, in the redirected URL
, the port number :9443
is missing and this result is not the expected result.
I am not sure if I got the rule correct or something wrong with it.
Any help to fix this is much appreciated.
My requirements for this rule:
http:
requests made to only this application -> WebAppDemo
running under "Default Web Site"
should be redirected to the https:
site which is bound to "WebAppDemo Site" -> WebAppDemo
on the custom port :9443
Note:- There are other applications and i do not want to redirect their http urls to https: that is why i specified a URL match.
<rules>
<rule name="WebAppDemo Https Redirect" stopProcessing="true">
<match url="WebAppDemo(/.*)?$" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTP_HOST}" pattern="([^/:]+)(:[^/]*)?" />
</conditions>
<action type="Redirect" url="https://{C:1}:9443/{R:0}" appendQueryString="false" />
</rule>
</rules>