0
votes

Similar question was asked many times but I'm still strugglin with "one page excluded" part. I based my solution on e.g. iis url redirect http to non www https but this solution is not 100% . It doesn't work for [https www domain com] to [https domain com] (part of www to non-www was early reverted)

I'm looking to exclude link http_://www.domain.com/ezine/some-more-url

Here is where I got so far:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Canonical Host Name (HTTP)" stopProcessing="true">
                    <match url="(.*)" />

                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTPS}" pattern="OFF" />
                        <add input="{HTTP_HOST}" pattern="(?=^domain\.com)(?=^(.(?!\/ezine\/))*$)" />
                    </conditions>

                    <action type="Redirect" url="http://www.domain.com/{R:1}" redirectType="Permanent" />
                </rule>

                <rule name="Canonical Host Name (HTTPS) www" stopProcessing="true">
                    <match url="(.*)" />

                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTPS}" pattern="OFF" />
                        <add input="{HTTP_HOST}" pattern="(?=^www.domain\.com)(?=^(.(?!\/ezine\/))*$)" />
                    </conditions>

                    <action type="Redirect" url="https://www.domain.com/{R:1}" redirectType="Permanent" />
                </rule>

                <rule name="Canonical Host Name (HTTPS)" stopProcessing="true">
                    <match url="(.*)" />

                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTPS}" pattern="ON" />
                        <add input="{HTTP_HOST}" pattern="(?=^domain\.com)(?=^(.(?!\/ezine\/))*$)" />
                    </conditions>

                    <action type="Redirect" url="https://www.domain.com/{R:1}" redirectType="Permanent" />
                </rule>

            </rules>
        </rewrite>
    </system.webServer>
</configuration>

I've tested regular expression and it seems fine. Any reason why it still redirects on http_://www.domain.com/ezine/some-more-url to https_://www.domain.com/ezine/some-more-url. Everything else is working

For those who ask why do I need it excluded: (but this is a different story)

Exception: Source:System, Message:The underlying connection was closed: 
Could not establish trust relationship for the SSL/TLS secure channel., 

InnerException:System.Security.Authentication.AuthenticationException: 
The remote certificate is invalid according to the validation procedure. 
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception) at
System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken m 
1

1 Answers

0
votes

I'm not sure if this will be usefull for anybody, but I finaly got it sorted:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="Canonical Host Name (HTTP)" stopProcessing="true">
                <match url="(.*)" />

                <conditions logicalGrouping="MatchAll">
                    <add input="{HTTPS}" pattern="OFF" />
                    <add input="{HTTP_HOST}" pattern="^domain\.com$" />
                    <add input="{URL}" pattern="^(.(?!ezine\/))*$" />                                   
                </conditions>

                <action type="Redirect" url="http://www.domain.com/{R:1}" redirectType="Permanent" />
            </rule>
            <rule name="Canonical Host Name (HTTPS) www" stopProcessing="true">
                <match url="(.*)" />

                <conditions logicalGrouping="MatchAll">
                    <add input="{HTTPS}" pattern="OFF" />
                    <add input="{HTTP_HOST}" pattern="^www.domain\.com$" />
                    <add input="{URL}" pattern="^(.(?!ezine\/))*$" />                                   
                </conditions>

                <action type="Redirect" url="https://www.domain.com/{R:1}" redirectType="Permanent" />
            </rule>
            <rule name="Canonical Host Name (HTTPS)" stopProcessing="true">
                <match url="(.*)" />

                <conditions logicalGrouping="MatchAll">
                    <add input="{HTTPS}" pattern="ON" />
                    <add input="{HTTP_HOST}" pattern="^domain\.com$" />
                </conditions>

                <action type="Redirect" url="https://www.domain.com/{R:1}" redirectType="Permanent" />
            </rule>

        </rules>
    </rewrite>      
</system.webServer>
</configuration>