How to deploy Create React App to Hostinger?
Asked Answered
R

2

5

Im having a problem viewing the subpages of my website that i deployed to Hostinger root folder or equivalent(subdomain), I run "npm run build" and deploy the files inside "build" folder to hostinger.

Of course it works on my local and firebase, but not on Hostinger.

See the files below for home, inner pages and FTP content.

home:

enter image description here

subpages:

enter image description here

ftp content from "build" folder.

enter image description here

Thanks!

Rocaille answered 28/8, 2021 at 10:7 Comment(0)
R
6

I got this here are the steps:

  1. Create .htaccess inside your 'public' folder and paste the ff code.

<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>
  1. Build the app using the command below.

    npm run build OR yarn build

  2. And deploy your 'build' folder to your root folder or equivalent(subdomains).

That's it, It works to me.

Rocaille answered 1/9, 2021 at 3:37 Comment(0)
S
0
  1. Create Build on Your local computer

    npm run build

  2. upload only build folder on hostinger

    all the files inside build must be moved to the public_html folder and delete the build folder ( as it is blank now )

  3. Congrats your React Site is Live

    Yes, you don't need any commands & configurations.

Salaam answered 3/8, 2023 at 18:30 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.