Options -Indexes
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

RewriteEngine On

# Allow cached favicon files.
RewriteRule ^uploads/cache/icons/[a-f0-9]+\.ico$ - [L]

# Protect private application files.
RewriteRule ^uploads/(cache|logs|cookie_consent)(/|$) - [F,L]

# Protect private plugin files.
RewriteRule ^plugins(/|$) - [F,L]

# Protect hidden files, while allowing certificate validation.
RewriteRule (^|/)\.(?!well-known(/|$)) - [F,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?altum=$1 [QSA,L]

<IfModule mod_headers.c>
    # Cache images.
    <filesMatch "\.(gif|ico|jpg|jpeg|png|svg|webp)$">
        Header set Cache-Control "max-age=31536000, public"
    </filesMatch>

    # Cache scripts, styles and icon fonts.
    <filesMatch "\.(js|css|woff2)$">
        Header set Cache-Control "max-age=31536000, public"
    </filesMatch>
</IfModule>

<IfModule mod_brotli.c>
    SetOutputFilter BROTLI_COMPRESS
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-brotli
    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "^fa-(solid-900|brands-400)\.woff2$">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>

    <Files ~ "sw\.js">
        Header set Service-Worker-Allowed: /
    </Files>
</IfModule>

<IfModule mod_headers.c>
    SetEnvIf Request_URI "^/uploads/pwa/" IS_PWA

    Header always set Access-Control-Allow-Origin "*" env=IS_PWA
    Header always set Access-Control-Allow-Methods "GET, OPTIONS" env=IS_PWA
    Header always set Access-Control-Allow-Headers "Content-Type" env=IS_PWA
</IfModule>

