# =====================================================================
# 1. ATURAN ROUTING, HTTPS, & CANONICAL DOMAIN (SUBFOLDER CPANEL - HTML STATIC)
# Konfigurasi khusus untuk domain HTML statis di folder public_html/bandit4dsee.com
# =====================================================================
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # A. PAKSA TRAFIK KE HTTPS DAN CANONICAL HOST (www / non-www)
    #     # Paksa HTTPS + NON-WWW (canonical memakai bandit4dsee.com)
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www\.bandit4dsee\.com$ [NC]
    RewriteRule ^(.*)$ https://bandit4dsee.com/$1 [R=301,L]

    # B. ATURAN UTAMA DOKUMEN INDEX
    DirectoryIndex index.html

    # C. SEMBUNYIKAN EKSTENSI .HTML DARI URL (Clean URL untuk Website Statis)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.html -f
    RewriteRule ^([^/]+)$ $1.html [L]

    # D. JALUR REDIRECT ERROR 404 (Opsional)
    # ErrorDocument 404 /404.html
</IfModule>

# =====================================================================
# 2. BENTENG PERTAHANAN: BLOKIR BOT DMCA, PINTEREST & CRAWLER KOMPETITOR
# Jika di robots.txt hanya berupa imbauan, di .htaccess ini server langsung memblokir total (Error 403)
# =====================================================================
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_USER_AGENT} ^.*(dmca|copyright|Lumen|LumenAPI|AhrefsBot|MJ12bot|SemrushBot|DotBot|Rogerbot|Pinterest|Pinterestbot) [NC]
    RewriteRule ^(.*)$ - [F,L]
</IfModule>

# =====================================================================
# 3. OPTIMASI RESOURSE SERVER & CACHING (Selaras dengan Crawl-Delay: 10)
# =====================================================================
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript application/xml
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 month"

    ExpiresByType text/xml "access plus 0 seconds"
    ExpiresByType text/plain "access plus 0 seconds"
    ExpiresByType application/xml "access plus 0 seconds"
</IfModule>

# =====================================================================
# 4. PROTEKSI KEAMANAN DIREKTORI INTERNAL DOMAIN
# =====================================================================
Options -Indexes

<Files .htaccess>
    Order Allow,Deny
    Deny from all
</Files>
