<IfModule mod_rewrite.c>
    RewriteEngine on

    # Mencegah akses ke file sensitif
    <FilesMatch "(\.env|\.htaccess|\.git|\.DS_Store|composer\.(json|lock)|phpunit\.xml)$">
        Require all denied
    </FilesMatch>

    # Rewrite rules
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

    # Menonaktifkan directory browsing
    Options -Indexes
</IfModule>

# Header Keamanan
<IfModule mod_headers.c>
    # Mencegah MIME sniffing
    Header set X-Content-Type-Options "nosniff"
    # Mencegah serangan clickjacking
    Header set X-Frame-Options "DENY"
    # Mencegah serangan XSS
    Header set X-XSS-Protection "1; mode=block"
    # Memaksa koneksi HTTPS
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
</IfModule>

# Mencegah hotlinking
<IfModule mod_rewrite.c>
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^https?://(www\.)?sipanter.bwssumvi\.com/ [NC]
    RewriteRule \.(jpg|jpeg|png|gif|bmp|webp)$ - [F,NC]
</IfModule>

# Mengizinkan akses ke file font
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>
</FilesMatch>

<IfModule !mod_rewrite.c>
    # Jika mod_rewrite tidak tersedia, kirim semua 404 ke Google
    ErrorDocument 404 http://google.com
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php56___lsphp .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
