Back

How to Deploy React App on Cpanel

Copy Below Code View As A Text File Show Text Only Show API Edit Code
                            

================= My Answer on Stack ============= Link == https://stackoverflow.com/questions/49939601/how-to-deploy-a-react-app-on-cpanel/64781141#64781141 =========== Manual Description ======== Step 1) Go to Package.json file and add this Property "homepage":"http://yourdomain.com" and paste your domain within it. Like Step 2) Now build the App using npm run build In your project directory it will create a build folder and it will contain all your static files for project. Zip all files and upload on your cpanel directory where your website run. Step 3) Create an .htaccess file and Place it on root directory. And paste the below code in .htaccess file. <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> ======== RUN Project Inside Directory ========== if you wish to run project inside a directory and you dnt want Domain / Sub domain for the project then do below. Go to App.JS --- <BrowserRouter basename="/react_store"> Add basename="Directory Name" Now Run your Project. It will Work. Thanks