<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /rhelektronik.com/

  # API requests - forward to PHP
  RewriteCond %{REQUEST_URI} ^/rhelektronik\.com/api/(.*)$
  RewriteRule ^api/(.*)$ api/index.php [QSA,L]

  # React Router - handle frontend routes
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !^/rhelektronik\.com/api/
  RewriteRule . /rhelektronik.com/index.html [L]
</IfModule>

# Security
<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
</IfModule>

# Compression
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json
</IfModule>

ErrorDocument 404 /rhelektronik.com/index.html
