# ---------------------------------------------------------------
# Configuracao geral - compativel com cPanel / Apache
# ---------------------------------------------------------------
Options -Indexes
DirectoryIndex index.php index.html

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Forcar HTTPS (descomente depois de ativar o SSL no cPanel)
  # RewriteCond %{HTTPS} off
  # RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # Forcar www (opcional - descomente se preferir com www)
  # RewriteCond %{HTTP_HOST} !^www\. [NC]
  # RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# Compressao
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript
  AddOutputFilterByType DEFLATE application/javascript application/x-javascript
  AddOutputFilterByType DEFLATE application/json image/svg+xml
</IfModule>

# Cache do navegador
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpeg      "access plus 1 year"
  ExpiresByType image/png       "access plus 1 year"
  ExpiresByType image/webp      "access plus 1 year"
  ExpiresByType image/avif      "access plus 1 year"
  ExpiresByType image/svg+xml   "access plus 1 year"
  ExpiresByType image/x-icon    "access plus 1 year"
  ExpiresByType video/mp4       "access plus 1 year"
  ExpiresByType text/css        "access plus 1 month"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
</IfModule>

# Cabecalhos de seguranca
<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# Bloqueia arquivos sensiveis
<FilesMatch "\.(sql|log|lock|md|json)$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order allow,deny
    Deny from all
  </IfModule>
</FilesMatch>

# Paginas de erro
ErrorDocument 404 /index.php
