##
# @package    Joomla
##

## No directory listings
Options -Indexes

## Enable rewriting
RewriteEngine On

## IMPORTANTE: Base correcta
RewriteBase /

## Evitar acceso a archivos sensibles
<FilesMatch "\.(ini|phps|fla|psd|log|sh)$">
  Require all denied
</FilesMatch>

## Proteger configuration.php
<Files configuration.php>
  Require all denied
</Files>

## 🔥 REDIRECCIÓN CANÓNICA (evita duplicados)
RewriteCond %{HTTP_HOST} ^retirum\.cl [NC]
RewriteRule ^(.*)$ https://www.retirum.cl/$1 [L,R=301]

## 🔥 ELIMINAR index.php DE LAS URLS
RewriteCond %{THE_REQUEST} \s/index\.php [NC]
RewriteRule ^index\.php/(.*)$ /$1 [R=301,L]

## 🔥 REDIRECCIÓN PRINCIPAL DE JOOMLA
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

## Evitar acceso a carpetas ocultas (.git, etc)
RewriteRule (^|/)\. - [F]

## Compresión
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json
</IfModule>

## Cache navegador
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpg "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType text/css "access plus 1 week"
  ExpiresByType application/javascript "access plus 1 week"
</IfModule>

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

## PHP handler (NO TOCAR)
# php -- BEGIN cPanel-generated handler
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php82 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php8_module>
   php_flag display_errors Off
   php_value max_execution_time 300
   php_value max_input_time 600
   php_value max_input_vars 1000
   php_value memory_limit 128M
   php_value post_max_size 80M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php83"
   php_value upload_max_filesize 20M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 300
   php_value max_input_time 600
   php_value max_input_vars 1000
   php_value memory_limit 128M
   php_value post_max_size 80M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php83"
   php_value upload_max_filesize 20M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Configure el paquete “ea-php83” como el lenguaje de programación predeterminado “PHP”.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php83 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
