Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

713
Views
Deploy React in XAMPP

I'm new in React, and try to deploy app in my local machine using XAMPP. My problem is, when i tried to access the webpage, its gives 404 Not Found. When using npm start, its working properly.

enter image description here

I tried some advice from other similar question, but its still not working. This is my index.js

<React.StrictMode>
  <BrowserRouter basename='/react'>
    <Route exact path="/" component={Home} />
  </BrowserRouter>
</React.StrictMode>

And I put "homepage": "http://localhost/react/" in package.json

  "homepage": "http://localhost/react/",
  "name": "admin-dashboard-presensi",

After that, I run npm run build and move the folder to htdocs/react

enter image description here

This is what I put inside .htaccess:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Possible Error Sincaio:

1- You add url to package.json before you are build

2- missing to restart XAMPP server

3- make sure the folder build name is react, else rename directory or change base <BrowserRouter basename='/react'> and rebuild

4- also check the directory full path is correct, and its has permission which its allow you to visit it.

More Details: (Move the contents of the build folder into htdocs/react, not the build folder itself => Copied from @Phil)

If above points not work, you can check details bellow: I think you missing hosts and/or virtual host config:

<VirtualHost localhost:80>
    ServerName my-website.local
    ServerAlias www.my-website.local
    ServerAdmin webmaster@my-website.local
    DocumentRoot "path/to/your/build"
     <Directory path/to/your/build>
        Options Indexes FollowSymLinks MultiViews
  AllowOverride all
  Order Deny,Allow
        Allow from all
        Require all granted
    </Directory>
</VirtualHost> 

Also you need to add your new domain to hosts: vim /etc/hosts and add:

127.0.0.1 my-website.local

Another details may help you if its missing in your setup

Also, you need to make sure you are put .htaccess in public directory before build:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

and then add: "homepage": "http://www.my-website.local", to package.json

Rebuild again, and restart XAMPP.

Note: I add alias domain nested of normal localhost, its better, but you can ignore that.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!