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

810
Vistas
Problema al redirigir a la carpeta /pública en un proyecto Laravel en Apache

Tengo la siguiente situación con un proyecto Laravel. Subí el proyecto a un servidor Linux en la carpeta /var/www/html/tup.

Puedo acceder al sitio con el enlace http://www.example.com/tup/public como se muestra en esta imagen (Primera imagen)

Quiero acceder directamente sin ingresar público en la URL es decir http://www.example.com/tup

Probé con un archivo .htaccess en la carpeta principal del proyecto:

 <IfModule mod_rewrite.c> # That was ONLY to protect you from 500 errors # if your server did not have mod_rewrite enabled RewriteEngine On # RewriteBase / # NOT needed unless you're using mod_alias to redirect RewriteCond %{REQUEST_URI} !/public RewriteRule ^(.*)$ public/$1 [L] # Direct all requests to /public folder </IfModule>

Pero cuando entro a http://www.example.com/tup Laravel arroja un error 404 Not Found (Imagen de error 404) . Tengo que escribir http://www.example.com/tup/index.php para que Laravel me redirija como en esta imagen .

Parece que el archivo index.php no se detecta

En la carpeta pública a tengo otro archivo .htaccess:

 DirectoryIndex index.php index.html <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Send Requests To Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>

Ya modifiqué el archivo apache2.conf y configuré todo AllowOverride en All y también habilité mod_rewrite.

También agregué esta configuración en apache2.conf:

 <Directory /var/www/html/tup/public/> DirectoryIndex index.php Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>

Agradecería mucho cualquier tipo de ayuda.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Tienes que habilitar mod_rewrite :

 sudo a2enmod rewrite sudo service apache2 restart

y en 000-default.conf deberías tener algo como esto:

 <Directory /var/www/html/tup/public/> DirectoryIndex index.php Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all Require all granted </Directory>

esto redirigirá su sitio web (visite http://www.example.com ) al proyecto laravel

over 4 years ago · Santiago Trujillo Denunciar

0

agregue lo siguiente a 000-default.conf, luego podrá acceder sin ninguna regla de reescritura.

 DocumentRoot /var/www/html/tup/public <Directory /var/www/html/tup/public> Options FollowSymLinks MultiViews Require all granted </Directory>
over 4 years ago · Santiago Trujillo 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