This works fine on url’s like example.com/component
(react router fires upcomponent
), but fails on routes like example.com/component/othercomponent
. The react router can navigate fine to these hypothetical url’s once the app is loaded, but Apache is confused.
.htaccess
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule . /index.html [L] </IfModule>
On gist.github
Second version of .htaccess
RewriteEngine On RewriteBase / RewriteRule ^index.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L]
Apache and LiteSpeed server do not need to restart.
Similar Posts:
2,516