Fix 404 error not found in Ionic PWA build for Angular or React

Early morning hike near Apache Junction AZ

When you encounter a 404 error not found in your Ionic PWA build for Angular or React, it means that the server is unable to locate the requested file or resource. To fix this, you need to include an .htaccess in your Ionic project and add the following directives.

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # Pass all requests not referring directly to files in the filesystem to
  # index.html.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.html [L]
</IfModule>

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.