# Global Conferences API - URL rewrites + CORS
# Works at any path (no hard-coded RewriteBase).

Options -MultiViews -Indexes

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Block direct access to internal folders
    RewriteRule ^(config|core|endpoints|cache)(/|$) - [F,L]

    # If the request is for a real file or directory, serve it as-is
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Otherwise, route everything through index.php
    RewriteRule ^ index.php [QSA,L]
</IfModule>

<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
    Header set Access-Control-Allow-Methods "GET, OPTIONS"
    Header set Access-Control-Allow-Headers "Content-Type, X-API-Key, Authorization"
</IfModule>

