fix: htaccess + index raíz con soporte APP_BASE para subdirectorio /admin
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
Options -Indexes
|
||||
RewriteEngine On
|
||||
|
||||
# Servir archivos y carpetas reales directamente
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
# Todo lo demás pasa por index.php raíz
|
||||
RewriteRule ^ index.php [QSA,L]
|
||||
@@ -1,2 +1,17 @@
|
||||
<?php
|
||||
// Punto de entrada raíz — permite desplegar el proyecto en un subdirectorio
|
||||
// Si el servidor sirve desde /admin/, setea APP_BASE=/admin en .env
|
||||
$base = '';
|
||||
if (file_exists(__DIR__ . '/.env')) {
|
||||
foreach (file(__DIR__ . '/.env') as $line) {
|
||||
$line = trim($line);
|
||||
if (str_starts_with($line, 'APP_BASE=')) {
|
||||
$base = rtrim(trim(explode('=', $line, 2)[1]), '/');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($base !== '' && str_starts_with($_SERVER['REQUEST_URI'], $base)) {
|
||||
$_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], strlen($base)) ?: '/';
|
||||
}
|
||||
require_once __DIR__ . '/public/index.php';
|
||||
|
||||
Reference in New Issue
Block a user