RewriteEngine On
RewriteBase /

# Blokir URL porno aneh yang sering dipakai attacker
RewriteCond %{REQUEST_URI} /(bokep|boke[p]?|sex|xxx|xnxx|bf-asli-jepang|download-video-fb) [NC]
RewriteRule ^ - [F,L]

RewriteCond %{REQUEST_URI} ^/menu/(bokep|xxx|sex|bf|xnxx) [NC,OR]
RewriteCond %{REQUEST_URI} ^/layanan/bkps/(bokep|xxx|sex|avtub|video) [NC]
RewriteRule ^ - [F,L]

# KECUALI file yang memang harus jalan (index, api, dsb.)
<Files "index.php">
 Require all granted
</Files>

# 1. STOP if the file or folder actually exists (this fixes the CSS)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# 2. Rewrite for News/Berita
RewriteRule ^berita/([^/]+)/?$ berita/detail.php?slug=$1 [L,QSA]

# =====================================================
# 3. Clean URL redirect (.php → non-.php) for PAGES ONLY
# =====================================================
RewriteCond %{THE_REQUEST} \s/+CiviCore/([^\s?]+)\.php[\s?]
RewriteRule ^ %1 [R=301,L]

# =====================================================
# 4. Resolve clean URLs internally
# example: /dashboard → dashboard.php
# =====================================================
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
# End of .htaccess