# Ship Network Admin — Apache .htaccess
# Untuk cPanel / Apache shared hosting

Options -Indexes
ServerSignature Off

# Proteksi folder data (config & log)
<FilesMatch "^(config\.json|activity\.log|alerts\.json|aruba_token\.json)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Blokir akses langsung ke folder data
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Blokir akses ke /data/
    RewriteRule ^data/ - [F,L]

    # Paksa HTTPS (aktifkan jika domain sudah pakai SSL)
    # RewriteCond %{HTTPS} off
    # RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# Proteksi includes
<FilesMatch "\.php$">
    <IfModule mod_authz_core.c>
        # Apache 2.4+ — izinkan semua (diproteksi oleh session auth di PHP)
        Require all granted
    </IfModule>
</FilesMatch>

# Blokir akses langsung ke includes
<IfModule mod_rewrite.c>
    RewriteRule ^includes/ - [F,L]
</IfModule>

# Cache static assets
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType font/woff2 "access plus 1 month"
</IfModule>

# Keamanan header
<IfModule mod_headers.c>
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "no-referrer-when-downgrade"
</IfModule>

# PHP settings (sesuaikan jika hosting membatasi)
<IfModule mod_php8.c>
    php_value session.cookie_httponly 1
    php_value session.use_strict_mode 1
    php_value upload_max_filesize 10M
    php_value post_max_size 10M
    php_value max_execution_time 60
</IfModule>
