# ---------------------------------------------------------------------------
# Shared-hosting / sub-folder support
#
# Lets the site run when the web server's document root is this project
# folder instead of /public (e.g. public_html/ or public_html/my-site/).
# Every request is forwarded into /public; application files are never
# served. When the document root already points to /public this file is
# not used.
# ---------------------------------------------------------------------------

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Block direct access to application internals.
    RewriteRule ^(\.env.*|\.git.*|app|bootstrap|config|database|docs|resources|routes|storage|tests|vendor|node_modules)(/|$) - [F,L,NC]
    RewriteRule ^(composer\.(json|lock)|artisan|phpunit\.xml|.*\.md|\.editorconfig)$ - [F,L,NC]

    # Send everything else to the public folder.
    RewriteCond %{REQUEST_URI} !/public/
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    Require all denied
</IfModule>

# Belt and braces: never serve dotfiles (.env, .git ...) even without rewrite rules.
<FilesMatch "^\.">
    Require all denied
</FilesMatch>

# Never list directory contents.
Options -Indexes
