From 7aac8f28634bd477ee8c4b8bb6f7bb94c004f21e Mon Sep 17 00:00:00 2001 From: renee-png Date: Tue, 2 Jun 2026 19:01:48 -0400 Subject: [PATCH] Add .htaccess SPA fallback for Apache/LiteSpeed (Hostinger) Fixes a 404 when refreshing deep routes on Hostinger: serves index.html for any request that isn't a real file/directory so the client-side router handles the path. vercel.json doesn't apply on Apache hosts. Lives in public/ so Vite bundles it into dist/. Co-Authored-By: Claude Opus 4.8 --- public/.htaccess | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 public/.htaccess diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..64463b0 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,17 @@ +# SPA fallback for Apache / LiteSpeed (Hostinger). +# Without this, refreshing a deep route (e.g. /dashboard/accounting) returns a +# 404 because no static file exists there. This serves index.html for any +# request that isn't a real file or directory, so the client-side router can +# handle the route. + + RewriteEngine On + RewriteBase / + + # Serve existing files and directories as-is (assets, images, etc.). + RewriteCond %{REQUEST_FILENAME} -f [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^ - [L] + + # Everything else falls back to the SPA entry point. + RewriteRule ^ index.html [L] +