1
我正在使用Azure WebApps构建静态页面和节点网站的组合,我想定制404页面,但我无法使其工作。 大多数网站是静态的,但我有几条需要服务器代码的路线。我的web.config看起来如下:带节点和Azure Web应用程序的自定义静态错误页面
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By"/>
<add name="x-dns-prefetch-control" value="on"/>
</customHeaders>
</httpProtocol>
<handlers>
<add name="iisnode" path="src/server/index.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="static">
<match url="(?!dynamicroute).*$" ignoreCase="true"/>
<action type="Rewrite" url="dist{REQUEST_URI}"/>
</rule>
<rule name="dynamic">
<match url="(?:dynamicroute)(.*)$" ignoreCase="true"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="src/server/index.js"/>
</rule>
</rules>
</rewrite>
<!-- Make sure error responses are left untouched -->
<!--<httpErrors existingResponse="PassThrough"/>-->
<httpErrors errorMode="Custom" defaultResponseMode="File" existingResponse="PassThrough">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="~/404.html" responseMode="File" />
</httpErrors>
</system.webServer>
</configuration>
我已经试过的httpErrors
不同变化的path
,responseMode
值,除去existingResponse="PassThrough"
等,但我不能让它工作。
直接访问/404.html
作品。访问不存在的url时,服务器返回404错误,而不是我想要的自定义URL。 我在做什么错?
我知道我可以处理nodeland的所有事情,但是我希望尽可能避免这种情况。
我不知道我在做什么错误,但工作。非常感谢! –