# -----------------------------------------------------------------------
# @author     Akshari Solutions
# @copyright  (c) 2026 Akshari Solutions. All rights reserved.
# -----------------------------------------------------------------------
#
# Fallback for hosting where the domain's document root is this project
# folder instead of its public/ folder (how the Laravel 7 site was set up).
# Every request is passed into public/, so .env, vendor/, storage/, app/
# and the rest of the project can never be downloaded.
#
# Preferred set-up: point the domain's document root at public/ in
# cPanel > Domains; this file is then never used.

Options -Indexes

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Live domain only: http:// and the bare domain -> https://www.
    # (same rules as public/.htaccess, needed here because public/ only
    # sees the request after it has been forwarded internally).
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{REQUEST_URI} !^/\.well-known/ [NC]
    RewriteCond %{HTTP_HOST} ^(www\.)?yyczonedrivingacademy\.com$ [NC]
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP:X-Forwarded-Proto} !=https
    RewriteRule ^(.*)$ https://www.yyczonedrivingacademy.com/$1 [R=301,L,NE]

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{REQUEST_URI} !^/\.well-known/ [NC]
    RewriteCond %{HTTP_HOST} ^yyczonedrivingacademy\.com$ [NC]
    RewriteRule ^(.*)$ https://www.yyczonedrivingacademy.com/$1 [R=301,L,NE]

    # Old /public/... asset URLs -> same file without the prefix.
    RewriteCond %{THE_REQUEST} \s/+public/ [NC]
    RewriteRule ^public/(.*)$ /$1 [R=301,L,NE]

    # SSL validation files stay reachable where cPanel puts them.
    RewriteRule ^\.well-known/ - [L]

    # Everything else is served from public/.
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

# If mod_rewrite is ever missing, refuse everything rather than expose
# the project files.
<IfModule !mod_rewrite.c>
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php84” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php84 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
