When you create and deploy a static html website on Azure static web apps, the 404 page will show a default Azure 404 page. Here is the code to change this page to a custom 404 page.

Create a custom 404 page on an Azure static web app.

Create file staticwebapp.config.json in the root of your website.

Enter this json:

{
  "responseOverrides": {
    "404": {
      "rewrite": "/404.html",
      "statusCode": 404
    }
  }
}

Create 404.html with your custom error.

Written by Loek van den Ouweland on 2021-08-09.
Questions regarding this artice? You can send them to the address below.