Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

712
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda