1
votes

I'm trying to work in a rewrite problem, but its my first time and I guess I'm doing something very wrong.

A few users of our portal, try to navigate typing https://www.dudalina.proveagora.com instead the right one https://dudalina.proveagora.com. We have the SSL only for *.proveagora.com, so I started to try a redirect on the users who type the wrong url. Here, the print of rewrite working great: enter image description here

but, some users type https:// and some users type http://. By this way, I've tried to change the pattern.

enter image description here

I dont know why, but using the second pattern, the url https://www.dudalina.proveagora.com doesnt redirect anymore.

Just to explain a little more, the dudalina part is dynamic too. Dudalina is the store name, and it will change accordingly with store. So, we can have latter something like http://bestbuy.proveagora.com or anything else and this patterns much works with all the options.

I know, the user cant type www.bestbuy.proveagora.com but they do, and we need to make it works! :(

Any help?

EDIT

xml Web.Config

     <rewrite>
        <rules>
            <rule name="RemoveWWWPrefix" stopProcessing="true">
                <match url="(.*)" negate="false" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                    <add input="{HTTP_HOST}" pattern="^(https\:\/\/|https\:\/\/)?([a-zA-Z]+\.)?(proveagora\.com){1}(\/.*)?$" ignoreCase="false" negate="true" />
                </conditions>
                <action type="Redirect" url="http://dudalina.proveagora.com" appendQueryString="false" />
            </rule>
        </rules>
    </rewrite>
1
Can you post the result from the web.config file? Your ultimate goal is to avoid any user to reach *.dudalina.proveagora.com with https and if it happens, to redirect them to dudalina.proveagora.com keeping the https protocol, is that right?cheesemacfly
@cheesemacfly you're right! I will post the xml web.config on the post! ThanksLeandro De Mello Fagundes

1 Answers

0
votes

Here you go:

<rule name="RemoveWWWPrefix" stopProcessing="true">
  <match url="(.*)" negate="false" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
    <add input="{HTTP_HOST}" pattern="^(.+\.)proveagora\.com$" />
    <add input="{HTTP_HOST}" pattern="^dudalina\.proveagora\.com$" negate="true" />
    <add input="{HTTPS}" pattern="^ON$" />
  </conditions>
  <action type="Redirect" url="https://dudalina.proveagora.com" appendQueryString="false" />
</rule>

What it will check is that the protocol used is HTTPS and that the subdomain of proveagora.com is present and different from dudalina.

If that's the case, it redirects to https://dudalina.proveagora.com