Options -Indexes
RewriteEngine On

# Jangan rewrite file/dir yang memang ada
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# API route
RewriteRule ^api/shortlinks$ api/shortlinks.php [L,NC]

# Shortcode: /Abc_123 atau /x-y_z
RewriteRule ^([A-Za-z0-9_-]{3,32})$ index.php?code=$1 [L,QSA]
# Block dotfiles
RewriteRule "(^|/)\." - [F]

# Block sensitive folders
RewriteRule ^(vendor|app|tests|sql)/ - [F,NC]

# Block sensitive files
<FilesMatch "^(composer\.(json|lock)|phpunit\.xml|phpcs\.xml|phpstan\.neon|\.php-cs-fixer\.php)$">
  Require all denied
</FilesMatch>