<IfModule mod_rewrite.c>
    RewriteEngine On

    # Preserve cPanel certificate validation and CGI endpoints.
    RewriteRule ^(?:\.well-known|cgi-bin)(?:/|$) - [L,NC]

    # Never expose Laravel application or dependency directories.
    RewriteRule ^(?:app|bootstrap|config|database|deployment|lang|resources|routes|storage|vendor)(?:/|$) - [F,L,NC]

    # Never serve project metadata or command-line entry files.
    RewriteRule ^(?:artisan|composer\.(?:json|lock)|INSTALLATION\.md|\.env(?:\..*)?)$ - [F,L,NC]

    # Shared-hosting fallback when the domain document root cannot be changed
    # from public_html to public_html/public.
    RewriteCond %{REQUEST_URI} !^/public/ [NC]
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
