# ============================================================
# Qudina Fintech - Apache Security Configuration
# ============================================================

# Disable directory browsing
Options -Indexes

# Disable server signature
ServerSignature Off

# Protect sensitive files
<FilesMatch "^\.">
    Order allow,deny
    Deny from all
</FilesMatch>

# Deny access to config, includes, sql folders
RewriteEngine On
RewriteRule ^(config|includes|sql)/.*$ - [F,L]

# Deny access to .env files
<FilesMatch "\.env$">
    Order allow,deny
    Deny from all
</FilesMatch>

# PHP settings (if mod_php is used)
<IfModule mod_php.c>
    php_flag display_errors off
    php_flag log_errors on
    php_value upload_max_filesize 5M
    php_value post_max_size 5M
    php_value max_execution_time 30
    php_value memory_limit 128M
</IfModule>

# Enable gzip compression
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript application/json
</IfModule>

# Cache static assets
<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>

# CORS Headers (already handled in PHP, but backup here)
<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"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
