# ========================================================================
# Olivo POS — public document root
#
# Keep this file in the public/ directory. Apache mod_rewrite is required for
# friendly routes such as /install/license and /app/pos. When rewrites are not
# available, open install.php; that direct installer uses install.php?route=...
# for its own wizard forms.
# ========================================================================

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Pass the real scheme through when TLS terminates at a trusted proxy.
    RewriteCond %{HTTP:X-Forwarded-Proto} =https
    RewriteRule ^ - [E=HTTPS:on]

    # Preserve authorization headers on CGI/FastCGI setups.
    RewriteCond %{HTTP:Authorization} .
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Never serve hidden or source/configuration-style files accidentally copied here.
    RewriteRule ^\.[^/]+$ - [F,L]
    RewriteRule ^(?!index\.php$|install\.php$).+\.php$ - [F,L,NC]
    RewriteRule \.(?:sql|log|lock|ini|env|bak|swp|dist|sample|phar|sh|md|json)$ - [F,L,NC]

    # The root request is the app front controller. For other directories,
    # return 403 rather than letting a host's global Indexes option list files.
    RewriteRule ^$ index.php [L]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.+$ - [F,L]

    # Serve real static files; send all remaining paths through the router.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]
    RewriteRule ^ index.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    DirectoryIndex index.php
    ErrorDocument 404 /index.php
</IfModule>
