Skip to main content

.htaccess file for React Router

· One min read
Luke Owen
Lead Front End Developer @ Lunio

If you’re using react-router as part of your React project, you’ll need to add a .htaccess file in order for it to work on the server.

This snippet will forward all URLs to index.html

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]