Home > AI > Server > Apache >

router refresh/direct/go back get wrong

If you are hosting you React APP on Apache server, and if the routing works fine locally but not on server and you encouter the following problems on your server.

  1. cannot refresh page
  2. cannot directly input the url

Then, you need to config .htaccess on your server.

RewriteEngine On  
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html [L]

Leave a Reply