Single Page Application for Lunarpages Hosting

Quick notes for deploying a ReactJS application to a basic website hosted by Lunarpages.

  1. use the control panel to create a subdomain eg. “my-spa”
  2. add the following .htaccess file to the new folder in the public html folder – “/my-spa/”
  3. publish the production build of the SPA to the folder
  4. point browser to

The extra notes in the .htaccess file are my own understanding of how it works, so reading with a critical eye is recommended.

reference links:

Contents of .htaccess file starts here:

RewriteEngine On
# set to Off to disable runtime rewriting
# set the base URL prefix
# not sure this does anything for my case
RewriteBase /
# for requests for index.html, just respond with the file
# regex ^=start, $=end, -=no substitution,[L]=last rule just do index.html
RewriteRule ^index\.html$ – [L]
# if requested path is not a valid filename, continue rewrite
# !-f=not a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# if requested path is not a valid directory, continue rewrite
# !-d=not a valid directory(treats req filename as directory)
RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule does the transformation if preceding RewriteConds are all true
# if you have continue to here, respond with index.html
# only do if preceding RewriteCond are true
# .=any single character(anything?),[L]=last rule just do index.html
RewriteRule . /index.html [L]
# source and reference info