# Apache config for cPanel shared hosting (Truehost).
# Astro copies this file from public/ into dist/ on every build.

Options -Indexes
DirectoryIndex index.html
ErrorDocument 404 /404.html

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Let cPanel AutoSSL validate the domain before HTTPS exists.
  RewriteRule ^\.well-known/ - [L]

  # One canonical address: https://www.immanuelafrika.org
  # (skipped for the cPanel temporary URL and other hostnames)
  RewriteCond %{HTTP_HOST} ^(www\.)?immanuelafrika\.org$ [NC]
  RewriteCond %{HTTPS} !=on [OR]
  RewriteCond %{HTTP_HOST} ^immanuelafrika\.org$ [NC]
  RewriteRule ^ https://www.immanuelafrika.org%{REQUEST_URI} [R=301,L]

  # Old Wix addresses -> new pages (same list as astro.config.mjs).
  RewriteRule ^team-4/?$ /partners/ [R=301,L]
  RewriteRule ^supporters/?$ /partners/ [R=301,L]
  RewriteRule ^transition-house/?$ /programs/transition-house/ [R=301,L]
  RewriteRule ^volunteer/?$ /get-involved/ [R=301,L]
</IfModule>

<IfModule mod_headers.c>
  # Astro's /_astro/ files have content hashes in their names, so cache them for a year.
  <If "%{REQUEST_URI} =~ m#^/_astro/#">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </If>
</IfModule>

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css text/plain application/javascript application/json image/svg+xml application/xml
</IfModule>
