# Disable directory browsing
Options -Indexes
php_flag zlib.output_compression off

# ── Rewrite Engine ─────────────────────────────────────────────
<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    # Set RewriteBase — change this if installed in a subfolder
    # RewriteBase /fieldly/public/

    # Redirect to HTTPS
    # RewriteCond %{HTTPS} off
    # RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Remove trailing slashes
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Route all requests through CI4 front controller
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

    # Pass Authorization header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
