Skip to content

Add .htaccess for URL rewriting and client-side routing - #87

Merged
devaraj3 merged 1 commit into
mainfrom
feature/landing-page-performance
Jul 26, 2026
Merged

Add .htaccess for URL rewriting and client-side routing#87
devaraj3 merged 1 commit into
mainfrom
feature/landing-page-performance

Conversation

@devaraj3

Copy link
Copy Markdown
Owner

What changed

  • Added public/.htaccess with Apache rewrite rules (automatically copied into dist/ at build time, same as robots.txt/sitemap.xml)

Why

  • Direct visits to https://cadviewer.xyz/viewer were returning a server-level 404 — confirmed via a fresh incognito test after the previous merge
  • Root cause: vite-react-ssg now builds viewer.html as a real static file at the build root, but Apache had no rule mapping the clean URL /viewer to that file
  • This likely predates the SEO work entirely — nobody had tested a direct/fresh visit to /viewer before, since navigation always happened by clicking from the landing page
  • The new rules: serve real files/folders as-is, map clean URLs to their matching .html file (e.g. /viewerviewer.html), and fall back to index.html for anything else so unmatched paths still show the app's own 404 page instead of a generic host error page

Validation

  • npm run build (confirm dist/.htaccess exists with the exact intended content)
  • Live check after deploy: https://cadviewer.xyz/viewer loads correctly as a fresh direct visit (not just by clicking through from the homepage)
  • Live check: https://cadviewer.xyz/ and https://cadviewer.xyz/sitemap.xml etc. still work normally (unaffected)

Notes

  • No application code changed — this is purely a server routing rule
  • Assumes Hostinger's origin server is Apache or Apache-compatible (e.g. LiteSpeed), which reads .htaccess — if this doesn't resolve it after deploying, the server may need a different config, worth checking with whoever manages the Hostinger account
  • Local npm run preview won't reflect this fix, since .htaccess only applies on the real Apache server, not Vite's local preview — live verification is the real test

@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cad-viewer Ready Ready Preview, Comment Jul 26, 2026 10:33am

@devaraj3
devaraj3 merged commit f0a59e4 into main Jul 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant