RewriteEngine On
RewriteBase /crm/

# Allow direct access to public folder files
RewriteCond %{REQUEST_URI} ^/crm/public/ [NC]
RewriteRule ^ - [L]

# Allow direct access to api folder files
RewriteCond %{REQUEST_URI} ^/crm/api/ [NC]
RewriteRule ^ - [L]

# Route everything else to public/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php [L,QSA]

# Enable CORS
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"

# Disable directory listing
Options -Indexes
