# AddHandler application/x-httpd-ea-php82 .php

# ── Directory Index ──
DirectoryIndex index.php

RewriteEngine On

# ── Explicit RewriteBase for this subfolder ──
# AddHandler application/x-httpd-ea-php82 .php

# ── Directory Index ──
DirectoryIndex index.php

RewriteEngine On

# ── Explicit RewriteBase for this subfolder ──
RewriteBase /ai_admin/

# ── Block direct access to config, sensitive files ──
RewriteRule ^config/ - [F,L]
RewriteRule ^app/(Controllers|Models|Services|Helpers)/ - [F,L]
RewriteRule ^database/ - [F,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.(env|json|key|log|sql|bak)$ - [F,L]
RewriteRule ^storage/backups/ - [F,L]

# ── Rewrite ALL non-public/api requests to public/ ──
RewriteCond %{REQUEST_URI} !^/ai_admin/public/
RewriteCond %{REQUEST_URI} !^/ai_admin/api/officer/
RewriteRule (.*) public/$1 [L]
