0

I have an app created with create-react-app that I want to deploy in my apache server.

When I tried to access my react app running on my server, i had an error 404 on every routes created with react-router. Then i added a .htaccess file in my app directory with the following rules :

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

Now i'm able to reach the simple routes, like http://mywebsite/myroute.

But when I try to reach nested routes like http://mywebsite/myroute/subroute

I've got a blank page with the following errors :

Uncaught SyntaxError: expected expression, got '<'

and

The stylesheet https://mysite/test/static/css/main.85d72dcf.chunk.css was not loaded because its MIME type, "text / html", is not "text / css"

This happen only when i try to reach a subroute, even if the routes are just html without any css.

I can't find any clue on the web, so any help would be much appreciated.

prime
  • 25
  • 4
  • Does this answer your question? [How to setup apache server for React route?](https://stackoverflow.com/questions/44038456/how-to-setup-apache-server-for-react-route) – cbr Jun 04 '21 at 13:55
  • Hello, it does not, i already followed this answer and this is how i managed to create a .htaccess and be able to reach the main routes. But none of the answers in this topic allow me to reach my subroutes. – prime Jun 04 '21 at 13:59
  • And you've tried **all** of the solutions presented to that question? – cbr Jun 04 '21 at 14:08
  • I tried every diffrents suggestions but no matter what i have the exact same result : basic routes works fine but not subroutes :/ – prime Jun 04 '21 at 14:15

1 Answers1

0

I just solved the problem by adding in the of my index.html document. For some reasons it seems to be needed when using subroutes.

prime
  • 25
  • 4