0

Hay all I´m having a doubt over here and not sure if possible with web.config.

I have a web app in azure . Domain foo.bar.com is pointing to this webapp.

On the other had I have a CDN as well in azure with a sub domain which is www.foo.bar.com is pointing to this CDN .

the idea is that foo.bar.com redirects to www.foo.bar.com so to use this CDN.

Right now the picture is:

foo.bar.com > WEBAPP > redirect > www.foo.bar.com > DNS > CDN > webapp which is causing like to many redirects and sort of endless loop.

Is there a way with web.config to have some rule say something like:

if URL is www.foo.bar.com don´t redirect, stay on webapp. to have something like:

foo.bar.com > WEBAPP > redirect > www.foo.bar.com  and that´s it stay on webapp.

Tried something like this but is not working:

<rule name="www" stopProcessing="true">
                    <match url="https://foo.bar.com" ignoreCase="true" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="https://foo.bar.com" />
                    </conditions>
                    <action type="Redirect" url="https://www.foo.bar.com/{R:0}" redirectType="Permanent" />
                </rule>
Chanafot
  • 101
  • 3
  • Are you using Azure DNS? If so you could just point your root domain at the CDN and do away with any redirection. https://docs.microsoft.com/en-us/azure/cdn/cdn-map-content-to-custom-domain#create-a-cname-dns-record – Sam Cogan Jul 09 '20 at 20:16
  • no Im not. DNS is handled by third party and we don´t have accees. Just indicated to them cname and ip of webap and CDN so they point to them – Chanafot Jul 09 '20 at 20:37

0 Answers0