<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Block access to hidden files and folders (.git, .env, etc.)
    RewriteRule ^\.(.*)$ - [F,L]

    # Block direct access to storage, database, config, tests, app directories from browser
    RewriteRule ^(app|config|database|storage|tests|docs)/ - [F,L]

    # Rewrite all requests to index.php if not an existing file or directory
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

# Disable LiteSpeed Cache for dynamic PHP ERP responses to prevent stale CSRF tokens
<IfModule LiteSpeed>
    CacheLookup off
</IfModule>

# Prevent directory browsing safely
<IfModule mod_autoindex.c>
    Options -Indexes
</IfModule>

# UTF-8 Encoding default
AddDefaultCharset UTF-8

