Options -Indexes
ErrorDocument 404 /404.html
ErrorDocument 403 /404.html
RewriteEngine On
RewriteBase /
# Block sensitive files (web.config, dotfiles)
RewriteRule ^(web\.config|\..*)$ /404.html [L,NC]
# === /api routing — covers BOTH backends ====================================
#
# Apache (unlike nginx) cannot health-check an upstream, so it cannot auto-fall
# back from Node to PHP. The behaviour is:
#
# - mod_proxy available -> /api is proxied to the Node backend (127.0.0.1:3000)
# - mod_proxy NOT present -> /api is rewritten to the PHP front controller
#
# Typical shared hosting (Aruba, cPanel) has no mod_proxy, so it uses PHP
# automatically. On a VPS running Node, mod_proxy sends /api to Node.
#
# If you are on a server that HAS mod_proxy but you want to use PHP, comment out
# the mod_proxy block below.
# --- Node backend (if mod_proxy is available) ---
ProxyPreserveHost On
ProxyPass /api/ http://127.0.0.1:3000/api/ retry=0
ProxyPassReverse /api/ http://127.0.0.1:3000/api/
RequestHeader set X-Forwarded-For "%{REMOTE_ADDR}s"
RequestHeader set X-Forwarded-Proto "https"
# --- PHP backend (fallback when mod_proxy is absent) ---
RewriteEngine On
RewriteBase /
RewriteRule ^api/(.*)$ backend/core/index.php [QSA,L]
# === Static files ===========================================================
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]