# ========================================================================
# Olivo POS — project root (ABOVE the public document root)
#
# Preferred deployment: point the site's document root at public/ and keep
# this project directory completely outside the web root. This file is only
# used when the whole project folder is placed inside public_html.
# ========================================================================

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Deny direct access to source, configuration, migrations, private storage,
    # tests and documentation. RewriteRule is valid in .htaccess; Directory and
    # DirectoryMatch containers are not, and can turn every request into a 500.
    RewriteRule ^(?:app|config|database|storage|tests|bin|docs|vendor)(?:/|$) - [F,L,NC]

    # Protect project-root metadata and scripts without blocking the PHP front
    # controllers inside public/.
    RewriteRule ^\.[^/]+$ - [F,L]
    RewriteRule ^(?:[^/]+\.php|composer\.(?:json|lock)|phpunit\.xml|CPANEL-START-HERE\.txt|[^/]+\.(?:sql|log|lock|ini|env|bak|json|md|sample|dist))$ - [F,L,NC]

    # Never list the project root. This non-preferred layout is served at
    # /project/public; build the redirect from the browser URL prefix. A bare
    # relative "public/" can be expanded to an absolute filesystem path by
    # some cPanel alias/vhost configurations.
    RewriteCond %{REQUEST_URI} ^(.*?)/?$
    RewriteRule ^$ %1/public/ [R=302,L]

    # Serve public/ as this directory's site root. If public/ itself is in the
    # requested path, let public/.htaccess route it instead of nesting public/.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !/public/
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

<IfModule mod_autoindex.c>
    Options -Indexes
</IfModule>
