1

I am trying to figure out why the following code does not work. This is a copy of my web.config file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="false" destination="https://" exactDestination="false" />
        <rewrite>
            <rules>
                <rule name="server.child.domain.lcl redirect." patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*server.child.domain.lcl/*" />
                    <action type="Redirect" url="https://server.child.org/application" />
                </rule>
                <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>
            </rules>
            <rewriteMaps>
                <rewriteMap name="StaticRedirects" />
            </rewriteMaps>
        </rewrite>
    </system.webServer>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="false" destination="https://" exactDestination="false" />
        <rewrite>
            <rules>
                <rule name="Domain redirect." patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*Server.child.domain.lcl/*" />
                    <action type="Redirect" url="https://server.domain.org/application" />
                </rule>
                <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>
            </rules>
            <rewriteMaps>
                <rewriteMap name="StaticRedirects" />
            </rewriteMaps>
        </rewrite>
    </system.webServer>
</configuration>

The first rule is supposed to redirect from the local domain name to the public domain name. This is on the same server with the certificate installed for the public domain name.

The second rule is supposed to redirect from HTTP to HTTPS if someone is trying to access the website without SSL.

Neither one of these seems to be working. I have tried several iterations but nothing seems to work. Can someone help me?

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
Ken
  • 11
  • 2

0 Answers0