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.
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
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>