# PHP Built-in Server Configuration
# Use with: php -S localhost:8000 .htrouter

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    # Skip rewriting for real files and directories
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # API routes
    RewriteRule ^api/auth(.*)$ api/auth/index.php [QSA,L]
    RewriteRule ^api/dashboard(.*)$ api/dashboard/index.php [QSA,L]
    RewriteRule ^api/sessions(.*)$ api/sessions/index.php [QSA,L]
    RewriteRule ^api/stats(.*)$ api/stats/index.php [QSA,L]
    
    # Public files
    RewriteRule ^public/(.*)$ public/$1 [QSA,L]
</IfModule>

# Allow CORS
<IfModule mod_headers.c>
    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"
</IfModule>
