# Prevent direct access to sensitive directories
RewriteEngine On

# Block access to config, storage, app directories
RewriteRule ^config/ - [F,L]
RewriteRule ^storage/ - [F,L]
RewriteRule ^app/ - [F,L]
RewriteRule ^sql/ - [F,L]
RewriteRule ^docs/ - [F,L]

# Block access to sensitive files
RewriteRule \.(env|json|md|txt|sql|bak|backup|key)$ - [F,L]

# Redirect everything to public/ directory
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/$1 [L]

# Disable directory listing
Options -Indexes

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