title: .htaccess Rewrite for React using React Router
body: <p>I need to rewrite or add to my existing .htaccess file so that my hosting service (Hostinger) can use a single index.html file for all pages instead of trying to fetch a new file server-side. I am using React with React-Router and it does not understand how to use the paths correctly. </p>
  
  <p>Existing File:</p>
  
  <p>This was used to fix an issue with my SSL</p>
  
  <p>========================== File ===========================</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule ^(.*)$ https://www.matthewendicott.space/$1 [L,R=301] 
  
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule ^(.*)$ https://www.matthewendicott.space/$1 [L,R=301]
  </code></pre>
  
  <p>====================== Testing and Similar Issues ==============</p>
  
  <p>Here are a few things that I have tried:</p>
  
  <p><a href="https://hostpapasupport.com/set-301-permanent-redirect-using-htaccess/" rel="nofollow noreferrer">https://hostpapasupport.com/set-301-permanent-redirect-using-htaccess/</a></p>
  
  <p><a href="https://mediatemple.net/community/products/grid/204643080/how-do-i-redirect-my-site-using-a-htaccess-file" rel="nofollow noreferrer">https://mediatemple.net/community/products/grid/204643080/how-do-i-redirect-my-site-using-a-htaccess-file</a></p>
  
  <p>And here is a similar issue:</p>
  
  <p><a href="https://stackoverflow.com/questions/56248347/how-to-fix-404-error-when-directly-accessing-a-component-in-react?noredirect=1&amp;lq=1">How to fix &quot;404&quot; error when directly accessing a component in react</a></p>