添加 outboundRules 会破坏我的网站
Adding outboundRules breaks my website in azure
我有一个带有自定义域的 Azure 网站(我正在尝试安装 sendy),问题是当该站点从该自定义域呈现所有 HTML 链接时内容指向 mysite.azurewebsites.net
所以我决定重写 HTML 内容以指向正确的域,例如 subdomain.mysite.com 但是当我添加出站规则时,基本上站点中断向我发送此消息:
The page cannot be displayed because an internal server error has
occurred.
我启用了对诊断日志的跟踪,但目前还没有找到任何相关信息。
我的猜测是 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>
非常欢迎提出建议!
禁用 URL 压缩解决了这个问题。
基本上,这个配置就可以了
<system.webServer>
<urlCompression doStaticCompression="false" doDynamicCompression="false"/>
</system.webServer>
我有一个带有自定义域的 Azure 网站(我正在尝试安装 sendy),问题是当该站点从该自定义域呈现所有 HTML 链接时内容指向 mysite.azurewebsites.net
所以我决定重写 HTML 内容以指向正确的域,例如 subdomain.mysite.com 但是当我添加出站规则时,基本上站点中断向我发送此消息:
The page cannot be displayed because an internal server error has occurred.
我启用了对诊断日志的跟踪,但目前还没有找到任何相关信息。
我的猜测是 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>
非常欢迎提出建议!
禁用 URL 压缩解决了这个问题。
基本上,这个配置就可以了
<system.webServer>
<urlCompression doStaticCompression="false" doDynamicCompression="false"/>
</system.webServer>