Report this

What is the reason for this report?

I can't reach sub urls on my react app

Posted on December 18, 2024

I deployed my React application as static service. The app works fine for the root path (/), but when I try to access any subpage URL directly (e.g., /move-address-detail, /building-detail), I receive a 404 Not Found error.

I am using React Router for client-side routing, and I have added an .htaccess file in my project’s root directory with the following content:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.html [L]
</IfModule>

How can I resolve the 404 error and make app correctly serve the React app’s subpages?

Thanks in advance

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.