<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /server/
    
    # Handle preflight OPTIONS requests
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule ^(.*)$ $1 [R=200,L]
    
    # Route /api/booking to booking.php
    RewriteRule ^api/booking$ booking.php [L]
    
    # Route /api/contact to contact.php
    RewriteRule ^api/contact$ contact.php [L]
    
    # Health check endpoint
    RewriteRule ^api/health$ health.php [L]
</IfModule>

# Set CORS headers
<IfModule mod_headers.c>
    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Allow-Methods "GET, POST, OPTIONS"
    Header always set Access-Control-Allow-Headers "Content-Type"
</IfModule>

# Prevent access to sensitive files
<FilesMatch "(^#.*#|\.env|\.ini|\.log)$">
    Require all denied
</FilesMatch>

# Prevent directory listing
Options -Indexes

# Set default charset
AddDefaultCharset UTF-8

# Enable error logging
php_flag display_errors off
php_flag log_errors on
php_value error_log /var/log/php_errors.log
