# Enable URL Rewriting
RewriteEngine On
RewriteBase /

# Prevent direct access to traffic log file
<Files "traffic_log.txt">
    Order Allow,Deny
    Deny from all
</Files>

# Clean URL alias for analytics dashboard
RewriteRule ^analytics$ enhanced_traffic_analyzer_fixed.php [L]

# Optional: Force HTTPS (uncomment to enable)
#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Clean URLs - Convert paths to keyword parameter
# Example: /best-air-fryer becomes ?keyword=best-air-fryer
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/enhanced_traffic_analyzer_fixed\.php$
RewriteRule ^([a-zA-Z0-9\-_]+)/?$ index.php?keyword=$1 [L,QSA]

# Prevent directory listing
Options -Indexes
