RewriteEngine On RewriteBase / # Ensure that static files like .js, .css, and service worker are not affected by rewrite rules RewriteCond %{REQUEST_FILENAME} -f RewriteRule \.(js|css|png|jpg|jpeg|gif|svg|ico|json|map)$ - [L] # Ensure service worker is served from the /dist/ folder RewriteRule ^dist/sw\.js$ - [L] # For Single Page Application (SPA) routing RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] # Add the correct MIME type for .js and .json files AddType application/javascript .js AddType application/manifest+json .json