RewriteEngine On

# Redirect to HTTPS (optional - uncomment if needed)
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Remove .php extension from URLs
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

# Custom routes for better URLs
RewriteRule ^login$ auth/login.php [NC,L]
RewriteRule ^register$ auth/register.php [NC,L]
RewriteRule ^dashboard$ user/dashboard.php [NC,L]
RewriteRule ^about$ pages/about.php [NC,L]
RewriteRule ^contact$ pages/contact.php [NC,L]
RewriteRule ^features$ pages/features.php [NC,L]
RewriteRule ^pricing$ pages/pricing.php [NC,L]
RewriteRule ^faq$ pages/faq.php [NC,L]

# Error page
ErrorDocument 404 /pages/404.php

# Security headers
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options nosniff
    Header always set X-Frame-Options DENY
    Header always set X-XSS-Protection "1; mode=block"
</IfModule>

# Cache control
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType text/html "access plus 600 seconds"
</IfModule>