# ============================================================
# QR SaaS Platform - Rewrite Rules
# Works on XAMPP (enable mod_rewrite + AllowOverride All in
# httpd.conf/httpd-vhosts.conf), any cPanel/Apache hosting, and
# LiteSpeed (LSWS) hosting.
#
# NOTE: intentionally NOT wrapped in <IfModule mod_rewrite.c> —
# some LiteSpeed configurations don't report that exact module
# name, which makes the IfModule check fail and silently skips
# every rule inside it (including the critical /r/{slug} short-link
# redirect). RewriteEngine On is safe to call directly; on the rare
# host with no rewrite support at all, it's simply a no-op.
# ============================================================

RewriteEngine On

# If the app lives in a subfolder (e.g. /qr-saas/), RewriteBase
# auto-detects in almost all cases; leave as "/" if served from
# domain root. Uncomment and adjust only if links 404 despite this.
# RewriteBase /qr-saas/

# ---- Short redirect links: /r/{slug} -> r/index.php?slug={slug}
RewriteRule ^r/([a-zA-Z0-9_-]{1,30})/?$ r/index.php?slug=$1 [L,QSA]

# ---- Block direct access to sensitive folders
RewriteRule ^(config|helpers|database|storage)/ - [F,L]

# Never let the raw .sql / storage / config files be served if
# rewrite is somehow off (defense in depth for shared hosting).
<FilesMatch "\.(sql|log|env)$">
    Require all denied
</FilesMatch>

Options -Indexes
