Azure 重定向到自定义 404 页面

Azure redirect to custom 404 page

我正在尝试在 Azure 中配置 Web 应用程序,以便在 http 状态代码为 404 时重定向到 html 页面。这是 Azure 中的静态 html 站点。我添加了包含这些内容的 web.config 和 ApplicationHost.xdt 文件,但它没有执行任何操作:

<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Auto" defaultResponseMode="ExecuteURL" >
  <remove statusCode="404"/>
  <error statusCode="404" responseMode="ExecuteURL" path="http://www.website.com/404/index.html" />
</httpErrors>

我在进行这些更改后重新启动了网络应用程序,但它没有执行任何操作。

根据您的网络配置文件,如果将路径更改为 "/404/index.html",它将正常工作。请试一试。

<system.webServer>
    <httpErrors errorMode="Custom" existingResponse="Auto" defaultResponseMode="ExecuteURL" >
      <remove statusCode="404"/>
      <error statusCode="404" responseMode="ExecuteURL" path="/404/index.html" />
    </httpErrors>
  </system.webServer>