# Leaf Tasks — Apache configuration for the public document root.
#
# Use this file by pointing your domain's document root at this `public/`
# directory (cPanel → Domains → Manage → Document Root). Do not put the full
# application inside public_html.

Options -Indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    # If the site lives at the root of a domain, leave this commented.
    # For a subfolder install, set it to that folder (not supported by the
    # app's absolute links without further changes).
    # RewriteBase /

    # Pass the Authorization header through to PHP. Apache/FastCGI often
    # strips it, which would break the Bearer-token JSON API.
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Existing files and directories (CSS, JS, manifest) are served directly.
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Every other request goes through the front controller.
    RewriteRule ^ index.php [L]
</IfModule>

# Never expose dotfiles such as .env or .git if they are ever uploaded here.
<FilesMatch "^\.">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>

<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# Hashed Vite assets can be cached forever; the manifest must stay fresh.
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    ExpiresByType application/json "access plus 0 seconds"
</IfModule>

# Optional: force HTTPS after AutoSSL is active and working.
# <IfModule mod_rewrite.c>
#     RewriteEngine On
#     RewriteCond %{HTTPS} !=on
#     RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# </IfModule>
