Hi everyone,
I've set up a Single Page Application (SPA) using React, which means that all requests (even non-existent ones) should be routed to the index.html
, and my JavaScript application handle the rest.
To achieve this, I have created a .htaccess
file with the following rules:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [QSA,L]
I placed the .htaccess
file in the /DOMAIN/public_nodejs/public/
directory, but it is not working. When I access any URL that does not correspond to an existing file, the server's native 404 page appears.
Can anyone tell me why this is happening? Is there something wrong with the .htaccess
rules, or am I placing it in the wrong directory? So how can I make sure all requests are correctly routed to index.html
?