Keep old url but redirect to new url - IIS - Asp.Net - .aspx

techthiru 40 Reputation points

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

Allows only a http:80 binding on default port 80.

Users use this URL to access this web application like so -

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

Now, I want the users to keep using the old URL which is but be served/redirected to

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:

I am redirected to this URL :

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.

	<rule name="WebAppDemo Https Redirect" stopProcessing="true">
		<match url="WebAppDemo(/.*)?$" />
			<add input="{HTTPS}" pattern="^OFF$" />
			<add input="{HTTP_HOST}" pattern="([^/:]+)(:[^/]*)?" />
		<action type="Redirect" url="https://{C:1}:9443/{R:0}" appendQueryString="false" />
Internet Information Services
A set of technologies in the .NET Framework for building web applications and XML web services.
3,362 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sam Wu-MSFT 7,131 Reputation points Microsoft Vendor


    You can refer to this rule:

        <rule name="http to https" stopProcessing="true">             
          <match url="(.*)" />             
              <add input="{HTTPS}" pattern="^OFF$" />             
          <action type="Rewrite" url="https://{HTTP_HOST}:9443/{R:1} />

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.