Hi Dave,
This is something that I've had issues with for years (both the http to https and www to non-www)! I have asked for help multiple times and my host has told me to do various things, all of which I assumed would be the correct thing to do.
Thank you for your input. I added this between the rewrite tags in my existing web.config file:
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
Hope that does the trick! This is the whole file now:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".pl" allowed="false" />
</fileExtensions>
</requestFiltering>
</security>
<defaultDocument>
<files>
<add value="index.asp" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
<httpErrors errorMode="Custom">
<remove statusCode="401" subStatusCode="-1" />
<error statusCode="401" subStatusCode="-1" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="403" subStatusCode="-1" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />
<remove statusCode="405" subStatusCode="-1" />
<error statusCode="405" subStatusCode="-1" prefixLanguageFilePath="" path="error.asp" responseMode="File" />
<remove statusCode="406" subStatusCode="-1" />
<error statusCode="406" subStatusCode="-1" prefixLanguageFilePath="" path="error.asp" responseMode="File" />
<remove statusCode="412" subStatusCode="-1" />
<error statusCode="412" subStatusCode="-1" prefixLanguageFilePath="" path="error.asp" responseMode="File" />
<remove statusCode="501" subStatusCode="-1" />
<error statusCode="501" subStatusCode="-1" prefixLanguageFilePath="" path="error.asp" responseMode="File" />
<remove statusCode="502" subStatusCode="-1" />
<error statusCode="502" subStatusCode="-1" prefixLanguageFilePath="" path="error.asp" responseMode="File" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" subStatusCode="-1" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
Thanks so much for your help!
Kelley
UPDATE:
Just found this in a file named web.configBAK:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".pl" allowed="false" />
</fileExtensions>
</requestFiltering>
</security>
<defaultDocument>
<files>
<add value="index.asp" />
</files>
</defaultDocument>
<rewrite>
<rules>
<!--# Redirect to HTTPS-->
<rule name="Imported Rule 1">
<match url="(.*)" ignoreCase="false" />
<conditions>
<!--## Redirect HTTP to HTTPS-->
<!--# Only trigger rule if a non-ssl port is being used-->
<add input="{SERVER_PORT}" pattern="443" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https:mydomain.com/{R:1}" />
</rule>
<rule name="Redirects to domain" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^www.mydomain.com$" />
</conditions>
<action type="Redirect" url="https://mydomain.com/{R:0}" />
</rule>
</rules>
</rewrite>
<httpErrors errorMode="Detailed">
<remove statusCode="401" subStatusCode="-1" />
<error statusCode="401" subStatusCode="-1" prefixLanguageFilePath="C:\home\mydomain.com\wwwroot" path="error.asp" responseMode="File" />
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="403" subStatusCode="-1" prefixLanguageFilePath="C:\home\mydomain.com\wwwroot" path="error.asp" responseMode="File" />
<remove statusCode="405" subStatusCode="-1" />
<error statusCode="405" subStatusCode="-1" prefixLanguageFilePath="C:\home\mydomain.com\wwwroot" path="error.asp" responseMode="File" />
<remove statusCode="406" subStatusCode="-1" />
<error statusCode="406" subStatusCode="-1" prefixLanguageFilePath="C:\home\mydomain.com\wwwroot" path="error.asp" responseMode="File" />
<remove statusCode="412" subStatusCode="-1" />
<error statusCode="412" subStatusCode="-1" prefixLanguageFilePath="C:\home\mydomain.com\wwwroot" path="error.asp" responseMode="File" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" subStatusCode="-1" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />
<remove statusCode="501" subStatusCode="-1" />
<error statusCode="501" subStatusCode="-1" prefixLanguageFilePath="C:\home\mydomain.com\wwwroot" path="error.asp" responseMode="File" />
<remove statusCode="502" subStatusCode="-1" />
<error statusCode="502" subStatusCode="-1" prefixLanguageFilePath="C:\home\mydomain.com\wwwroot" path="error.asp" responseMode="File" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>