Skip to content

Fix direct URL access (404) on cPanel/Apache for React Router SPA#9

Merged
mnaimfaizy merged 2 commits intomainfrom
copilot/investigate-web-app-build-issues
Mar 10, 2026
Merged

Fix direct URL access (404) on cPanel/Apache for React Router SPA#9
mnaimfaizy merged 2 commits intomainfrom
copilot/investigate-web-app-build-issues

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

React Router handles routing client-side, but Apache on cPanel returns 404 for any URL that doesn't map to a physical file — breaking direct navigation and page refreshes for all non-root routes.

Changes

  • public/.htaccess — Apache mod_rewrite rules that fall through to index.html for any request that isn't a real file or directory, letting React Router take over. Vite copies public/ verbatim into dist/, so no build changes are needed.

    Options -MultiViews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.html [QSA,L]
  • README.md — Added a Deploying to cPanel (Apache) section covering the root cause, upload steps (including the hidden-file caveat), mod_rewrite requirement, and a note that no Node.js server is required.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: mnaimfaizy <34773846+mnaimfaizy@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate build, deploy, and testing for cPanel environment Fix direct URL access (404) on cPanel/Apache for React Router SPA Mar 10, 2026
@mnaimfaizy mnaimfaizy marked this pull request as ready for review March 10, 2026 08:56
@mnaimfaizy mnaimfaizy merged commit 678da6e into main Mar 10, 2026
7 checks passed
@mnaimfaizy mnaimfaizy deleted the copilot/investigate-web-app-build-issues branch March 10, 2026 08:57
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.

2 participants