Options -Indexes

RewriteEngine On

# Hide .php from URL
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

# Enhanced bot blocking
RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
RewriteCond %{HTTP_USER_AGENT} (bot|crawler|spider|curl|wget|python|scrapy|headless|selenium|phantomjs|playwright|puppeteer|sqlmap|nikto|ahrefs|semrush|mj12bot|dotbot|rogerbot|screaming|masscan|zgrab) [NC]
RewriteRule ^ - [F,L]

# Referrer shield
RewriteCond %{HTTP_REFERER} (ahrefs|semrush|moz|majestic|googlebot) [NC]
RewriteRule ^ - [F,L]

ErrorDocument 403 "Access Restricted"