Options -Indexes

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # 1. EXCLUDE ASSETS — langsung stop, tanpa cek file exist
    RewriteRule ^(cdn-images|images-cdn|css|js|maintenance\.html) - [L]

    # 2. MAINTENANCE MODE (HANYA HOME)
    ErrorDocument 503 /maintenance.html
    RewriteCond %{REQUEST_URI} ^/($|index\.html?)$ [NC]
    RewriteCond %{REQUEST_URI} !^/maintenance\.html$ [NC]
    RewriteRule ^.*$ - [R=503,L]

    # 3. REDIRECT .HTML KE URL BERSIH TANPA MEMAKSA SLASH
    RewriteCond %{THE_REQUEST} \s/+(.*?)\.html[\s?] [NC]
    RewriteRule ^(.*)\.html$ /$1 [R=301,L]

    # 4. INTERNAL MAPPING UNTUK URL TANPA SLASH
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{DOCUMENT_ROOT}/$1.html -f
    RewriteRule ^([^/]+)$ $1.html [L]

    # 5. INTERNAL MAPPING UNTUK URL DENGAN SLASH
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{DOCUMENT_ROOT}/$1.html -f
    RewriteRule ^(.+)/$ $1.html [L]
</IfModule>