<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

# ---------------------------------------------------------------------------
# Performance (local development safe)
#
# 1) Compression: text assets are gzipped before they are sent. The rule set
#    only applies when mod_deflate is loaded (see httpd.conf).
# 2) Caching: CSS/JS/images get an explicit validator-based policy. CSS and JS
#    are revalidated on every load (access plus 0 seconds) so code changes are
#    still picked up immediately, while images/fonts are reused for a day.
#    Both blocks are no-ops when the matching module is unavailable.
# ---------------------------------------------------------------------------
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css text/csv
    AddOutputFilterByType DEFLATE text/javascript application/javascript application/json
    AddOutputFilterByType DEFLATE application/xml application/rss+xml
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE font/ttf font/woff font/woff2
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 0 seconds"
    ExpiresByType application/javascript "access plus 0 seconds"
    ExpiresByType image/png "access plus 1 day"
    ExpiresByType image/jpeg "access plus 1 day"
    ExpiresByType image/gif "access plus 1 day"
    ExpiresByType image/webp "access plus 1 day"
    ExpiresByType image/svg+xml "access plus 1 day"
    ExpiresByType image/x-icon "access plus 1 day"
    ExpiresByType font/woff "access plus 1 day"
    ExpiresByType font/woff2 "access plus 1 day"
</IfModule>
