Home Ask Login Register

Developers Planet

Your answer is one click away!

Programming Newbie February 2016

HTTPS redirect on sub application

I have an application with this domain http://abc.example.com/portal. Portal is a sub application to the main application (abc.example.com) on IIS.

I would like to redirect to https://abc.example.com/portal if anyone access it by http://abc.example.com/portal.

I added these lines to the web.config:

       <rule name="HTTPS Redirect" enabled="true">
           <match url="(.*)" ignoreCase="false" />
               <add input="{HTTPS}" pattern="off" />
           <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />

After this, if I call site http://abc.example.com/portal, it takes me to https://abc.example.com/ and not to https://abc.example.com/portal.

Do you guys have any idea how can I make this work?



Josh February 2016

Try changing your rule to:

<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}/{R:1}" />

Also, if the /example subdirectory is an application, make sure these rewrite rules are placed in that web.config and not the parent application's web.config.

Post Status

Asked in February 2016
Viewed 3,256 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life