# Simple .htaccess - NO CACHING
RewriteEngine On

# ===== SECURITY SETTINGS =====

# Prevent access to sensitive files
<Files "*.sql">
    Order Allow,Deny
    Deny from all
</Files>

<Files "*.log">
    Order Allow,Deny
    Deny from all
</Files>

<Files "config.php">
    Order Allow,Deny
    Deny from all
</Files>

<Files "functions.php">
    Order Allow,Deny
    Deny from all
</Files>

# ===== NO CACHE FOR EVERYTHING =====

# NO CACHE for ALL files
<FilesMatch ".*">
    Header always set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
    Header always set Pragma "no-cache"
    Header always set Expires "Thu, 01 Jan 1970 00:00:00 GMT"
    Header always set Last-Modified ""
    Header always set ETag ""
    FileETag None
</FilesMatch>

# Additional no-cache headers
Header always set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
Header always set Pragma "no-cache"
Header always set Expires "0"

# ===== STATIC FILES SERVING =====
# Allow direct access to CSS, JS, images, and other static files
RewriteCond %{REQUEST_URI} \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|pdf|zip|mp4|webm|ogg)$ [NC]
RewriteRule ^ - [L]

# ===== URL REWRITING =====
# Only rewrite if file/directory doesn't exist AND it's not a static file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|pdf|zip|mp4|webm|ogg)$ [NC]
RewriteRule ^(.*)$ index.php [QSA,L]

# ===== ADDITIONAL SECURITY HEADERS =====
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
