# Biarkan file statis tetap bisa diakses langsung
RewriteCond %{REQUEST_URI} \.(xml|css|js|jpg|jpeg|png|gif|webp|ico|svg|woff|woff2|ttf|txt)$ [NC]
RewriteRule ^ - [L]

# Redirect dari URL yang pakai .php ke versi tanpa .php (SEO-friendly)
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ https://www.hellomontelo.com/%1 [R=301,L]

# Jika file .php tersedia, izinkan akses URL tanpa .php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/.]+)$ $1.php [L]


# Handle 404 error dan redirect ke URL fallback dengan 301
ErrorDocument 404 /redirect-404-handler
RewriteCond %{REQUEST_URI} ^/redirect-404-handler$
RewriteRule ^.*$ https://www.hellomontelo.com/commercants/detail/mango [R=301,L]