我有一个带有自定义域的天蓝色网站(我正在尝试安装sendy),问题是当网站从该自定义域呈现时,内容中的所有 HTML 链接都指向 mysite.azurewebsites.net
所以我决定重写 HTML 内容以指向正确的域,例如 subdomain.mysite.com 但是当我添加出站规则时,基本上网站会中断向我发送此消息:
由于发生内部服务器错误,无法显示该页面。
我启用了对诊断日志的跟踪,但我现在还没有找到任何相关的东西。
我的猜测是 azure 默认启用 httpcompression 会导致问题,因为在使用压缩时不能进行 HTML 重写。
这是我的 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>
非常欢迎提出建议!