I have a website in azure with a custom domain (I'm trying to install sendy), the issue is when the site renders from that custom domain all the HTML links in the content are pointing to mysite.azurewebsites.net
SO I decided to rewrite the HTML content to point to the correct domain, like subdomain.mysite.com but when I add the outbound rule basically the site breaks sending me this message:
The page cannot be displayed because an internal server error has occurred.
I enabled the trace the diagnostic logs but I haven't found anything relevant for now.
my guess is that azure enables by default httpcompression causing the issue, because you can't do HTML rewrite when using compression.
this is my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<rewrite>
<outboundRules>
<rule name="Rewrite HTML" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Head, IFrame, Img, Input, Link, Script"
pattern="mysite.azurewebsites.net" />
<action type="Rewrite" value="subdomain.mysite.com" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
<rules>
<rule name="Sendy all" stopProcessing="true">
<match url="^([a-zA-Z0-9-]+)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.php" appendQueryString="true" />
</rule>
<rule name="Sendy: link tracker" stopProcessing="true">
<match url="^l/([a-zA-Z0-9/]+)$" ignoreCase="true" />
<action type="Rewrite" url="l.php?i={R:1}" appendQueryString="true" />
</rule>
<rule name="Sendy: open tracker" stopProcessing="true">
<match url="^t/([a-zA-Z0-9/]+)$" ignoreCase="true" />
<action type="Rewrite" url="t.php?i={R:1}" appendQueryString="true" />
</rule>
<rule name="Sendy: web version" stopProcessing="true">
<match url="^w/([a-zA-Z0-9/]+)$" ignoreCase="true" />
<action type="Rewrite" url="w.php?i={R:1}" appendQueryString="true" />
</rule>
<rule name="Sendy: unsubscribe" stopProcessing="true">
<match url="^unsubscribe/(.*)$" ignoreCase="true" />
<action type="Rewrite" url="unsubscribe.php?i={R:1}" appendQueryString="true" />
</rule>
<rule name="Sendy: subscribe" stopProcessing="true">
<match url="^subscribe/([a-zA-Z0-9/]+)$" ignoreCase="true" />
<action type="Rewrite" url="subscribe.php?i={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
suggestions are more than welcome!
Disabling the URL compression fixed the issue.
basically, this configuration does the trick
<system.webServer>
<urlCompression doStaticCompression="false" doDynamicCompression="false"/>
</system.webServer>