views:

24

answers:

0

I have ASP.NET application on IIS7 that I want to work only under SSL. I followed http://www.iis-aid.com/articles/how_to_guides/redirect_http_to_https_iis_7 and wrote following rewriting rule in web.config:

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

The problem is that when user type www.mysite.mg.gov it redirects him to https://www.mysite.mg.gov I would prefer to redirect him to https://mysite.mg.gov (without www) because I have certificate for whole domain (*.mg.gov) and with 'www' browser says that page is not trusted etc.