2

I have a Sitecore 8 application hosted in Azure. I have several domains subdomains that point to the same application but are deprecated and need to redirect to the main site. My main site is www.mysite.com. I have separate endpoints for each subdomain, such as www.mysite-nl.com with the endpoint hostname mysite-prod-01-cd-nl.azureedge.net. I have the following rewrite in my web.config, but it's not redirecting:

     <rule name="nl redirect" stopProcessing="true">
      <match url="(.*)" />
      <action type="Redirect" url="http:// www.mysite.com" redirectType="Permanent"/>
      <conditions>
        <add input="{HTTP_HOST}" pattern="^(www\.)?mysite-prod-01-cd-nl.azureedge.net$" />
      </conditions>
    </rule>
Erica Stockwell-Alpert
  • 4,624
  • 10
  • 63
  • 130
  • There is a space in your redirect URL. I'm not saying that's the problem but you might want to correct that. – Paul Jul 06 '18 at 00:46
  • Isn't Azureedge.net the domain of the CDN? How is the origin setup? – Jeroen Jul 09 '18 at 15:45

1 Answers1

0

It's not working because you've mixed <action> with <conditions>. In general:

  • Conditions – The optional conditions collection is used to specify additional logical operations to perform if a URL string matches the rule pattern. Within the conditions, you can check for certain values of HTTP headers or server variables, or verify if the requested URL corresponds to a file or directory on a physical file system.
  • Action – The action is used to specify what to do if the URL string matches the rule pattern and all the rule conditions are met.

So your action should redirect you like that:

<action type="Redirect" url="mysite-prod-01-cd-nl.azureedge.net" redirectType="Permanent"/>

More information's here: URL Rewrite Module Configuration Reference.

Dawid Rutkowski
  • 2,658
  • 1
  • 29
  • 36