# ==============================================================================
# TITAN / COSY POS ENGINE - HARDENED PRODUCTION APACHE CONFIGURATION
# ==============================================================================

# Disable Directory Browsing
Options -Indexes

# Follow Symbolic Links
Options +FollowSymLinks

# Block Access to Hidden & Sensitive Files (.env, .git, .sql, .log, .gz)
<FilesMatch "^\.|\.(env|log|sql|gz|sh|bak|config|md)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# Block access to parent config or source folders if webroot is set improperly
RedirectMatch 403 ^/(config|database|src|docs|logs)/.*$

# Enforce UTF-8 Default Charset
AddDefaultCharset UTF-8

# Secure HTTP 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"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# Static Asset Caching for Images, CSS, and JS
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/svg+xml "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
</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 image/svg+xml
</IfModule>
