# Aktifkan Rewrite Engine
RewriteEngine On

# Jangan tampilkan isi direktori
Options -Indexes

# Proteksi file sensitif
<FilesMatch "\.(sql|log|ini|md|txt)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# Lindungi folder config dan includes
RedirectMatch 403 ^/config/.*$
RedirectMatch 403 ^/includes/.*$

# Biarkan akses ke ajax hanya dari local? (jika diperlukan)
# Untuk saat ini biarkan terbuka karena dibutuhkan AJAX frontend.

# Redirect ke HTTPS (jika sudah pakai SSL, aktifkan baris di bawah)
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

# Hapus ekstensi .php dari URL (opsional, aktifkan jika Anda mau URL tanpa .php)
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_FILENAME}.php -f
# RewriteRule ^([^/]+)/?$ $1.php [L]

# Pengaturan default karakter
AddDefaultCharset UTF-8

# Kompresi GZIP untuk performa
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json
</IfModule>

# Cache browser (opsional)
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
</IfModule>