# =====================================================================
#  Veronet — .htaccess di public_html (root project Laravel)
#  Seluruh project ada di public_html; semua request diteruskan ke folder
#  public/. File di luar public/ (.env, vendor, storage, dll) tidak bisa
#  diakses dari browser.
#
#  Catatan: menu "MultiPHP Manager" cPanel bisa menambahkan blok
#  "php -- BEGIN cPanel-generated handler" di file ini. Biarkan saja.
# =====================================================================

Options -Indexes

# Lapisan pengaman tambahan: tolak file sensitif walau rewrite tidak aktif.
<FilesMatch "^(\.env.*|\.ht.*|\.frontend-files|artisan|composer\.(json|lock)|package(-lock)?\.json|phpunit\.xml|setup\.sh|.*\.(log|sql|sqlite|zip|md))$">
    Require all denied
</FilesMatch>

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Paksa HTTPS (cookie login memakai SESSION_SECURE_COOKIE=true).
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteCond %{REQUEST_URI} !^/\.well-known/
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Validasi SSL (AutoSSL / Let's Encrypt) tetap dari public_html/.well-known.
    RewriteRule ^\.well-known/ - [L]

    # Semua request lain → folder public/ (aturan lanjutan ada di public/.htaccess).
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
