IIS HTTP to HTTPS relative redirect

http, https, iis, redirect, ssl

Solution

I found a way to do this, and you don't need the Rewrite module for it. The following worked for me on Windows 8 (IIS 8.5):

- Remove the HTTP binding from your site (leave HTTPS in place)

- Add another site

- Make sure that the new site has HTTP binding

- Configure HTTP Redirect as shown:

Now all HTTP request will redirect to your HTTPS site and will preserve the rest of the URL.

Problem

I recently got a SSL certificate for my website and want to redirect all traffic to HTTPS. I got everything to go to `https://mydomain.com` but if someone enters `http://mydomain.com/anotherpage` it drops the other page and just takes the user to the home page. My rule in my `web.config` file looks like this: ``` <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule> ``` I also tried `https://{HTTP_HOST}{REQUEST_URI}` without any success. Can anyone tell me what I need to do to make the website redirect to the proper HTTPS version of the page? I have a feeling it has something to do with the pattern, but I can't seem to figure out the syntax.

Original source