0

I'm having a problem trying to force https on my website while excluding locahost I'm currently using Intelligencia.UrlRewriter to rewrite any urls and I have the following rule set up:

<if header="HTTPS" match="^OFF$">
<redirect url="(.*)" to="https://sub.mydomain.com$1" />
</if>

This redirects fine, but I would like to make sure that my localhost debugging is not affected. This obviously runs under a different URL. So I tried:

<if header="HTTPS" match="^OFF$">
<redirect url="(.*)mydomain" to="https://sub.mydomain.com$1" />
</if>

This however does not work. I believe the reason for that might be that it only evaluates anything after the .com. I have tried searching for documentation with no luck.

How can I always force https connection except on my localhost?

Riaan van Zyl
  • 538
  • 8
  • 17

1 Answers1

0

I managed to find a solution to my problem:

<unless header="HTTP_HOST" match="localhost">
  <if header="HTTPS" match="^OFF$">
    <redirect url="(.*)" to="https://sub.mydomain.com$1" />
  </if>
</unless>

With the addition of the <unless header="HTTP_HOST" match="localhost"> tag I can exclude certain hosts and still allow other hosts to be redirected to https. In other words:

This will be forced:


http://sub.mydomain.com/default.html

To (note the s in https):

https://sub.mydomain.com/defualt.html


But this will not be changed:

http://localhost/default.html


Riaan van Zyl
  • 538
  • 8
  • 17