Fix bootstrap config loading and root rewrites
This commit is contained in:
15
.htaccess
15
.htaccess
@@ -1,10 +1,19 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
# Redirect all requests to the public directory where the front controller lives
|
||||
RewriteCond %{REQUEST_URI} !^/public/
|
||||
# Allow direct access to files that actually exist in the public directory
|
||||
RewriteCond %{DOCUMENT_ROOT}/public/$1 -f
|
||||
RewriteRule ^(.*)$ public/$1 [L]
|
||||
|
||||
RewriteCond %{DOCUMENT_ROOT}/public/$1 -d
|
||||
RewriteRule ^(.*)$ public/$1/ [L]
|
||||
|
||||
# Block direct access to sensitive directories
|
||||
RewriteRule ^(app|bootstrap|config|database|resources|routes)/ - [F,L]
|
||||
|
||||
# Everything else goes through the front controller
|
||||
RewriteRule ^ public/index.php [QSA,L]
|
||||
</IfModule>
|
||||
|
||||
# Ensure the public front controller is used as the default directory index
|
||||
DirectoryIndex public/index.php
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
use App\Core\Config;
|
||||
|
||||
// Ensure the configuration class is loaded even if SPL autoloading is not yet available
|
||||
if (!class_exists(Config::class, false)) {
|
||||
$configPath = __DIR__ . '/../app/Core/Config.php';
|
||||
if (file_exists($configPath)) {
|
||||
require_once $configPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('config')) {
|
||||
function config(string $key, $default = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user