<IfModule mod_rewrite.c>
    RewriteEngine On

    # Canonical host: force HTTPS + www before routing to the public folder
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\.hosttiller\.com$ [NC]
    RewriteRule ^ https://www.hosttiller.com%{REQUEST_URI} [R=301,L]

    # Redirect everything to the public folder, avoiding loops if already inside public
    RewriteRule ^$ public/index.php [L]
    RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
</IfModule>