# =====================================================================
# SIPIUTANG - Konfigurasi Apache (cPanel)
# =====================================================================

# --------------------------------------------------------------- URL Rewrite
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Bila dipasang di subfolder, aktifkan baris berikut dan sesuaikan:
    # RewriteBase /sipiutang/

    # Paksa HTTPS (aktifkan setelah sertifikat SSL terpasang)
    # RewriteCond %{HTTPS} !=on
    # RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Lewatkan berkas & direktori yang benar-benar ada
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Semua permintaan lain diarahkan ke front controller
    RewriteRule ^ index.php [L]
</IfModule>

# --------------------------------------------------------------- Header Keamanan
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
    Header always unset X-Powered-By
    # Aktifkan HSTS hanya bila seluruh situs sudah memakai HTTPS
    # Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
</IfModule>

# --------------------------------------------------------------- Kompresi
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript
    AddOutputFilterByType DEFLATE application/javascript application/json application/xml
    AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>

# --------------------------------------------------------------- Cache Aset
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css                "access plus 7 days"
    ExpiresByType application/javascript  "access plus 7 days"
    ExpiresByType image/svg+xml           "access plus 30 days"
    ExpiresByType image/png               "access plus 30 days"
    ExpiresByType image/jpeg              "access plus 30 days"
    ExpiresByType font/woff2              "access plus 30 days"
</IfModule>

# --------------------------------------------------------------- Proteksi Berkas
<FilesMatch "^\.">
    Require all denied
</FilesMatch>
<FilesMatch "\.(sql|log|ini|md|json|lock|yml|yaml|sh|bak|old)$">
    Require all denied
</FilesMatch>

Options -Indexes
DirectoryIndex index.php

# --------------------------------------------------------------- Batas Unggah
<IfModule mod_php.c>
    php_value upload_max_filesize 32M
    php_value post_max_size 40M
    php_value max_execution_time 300
    php_value max_input_vars 5000
    php_value memory_limit 256M
</IfModule>
<IfModule lsapi_module>
    php_value upload_max_filesize 32M
    php_value post_max_size 40M
    php_value max_execution_time 300
    php_value max_input_vars 5000
    php_value memory_limit 256M
</IfModule>
