# Correct MIME type for favicon
AddType image/x-icon .ico

RewriteEngine On

# Redirect old tandem page to new SEO-friendly URL (full https://www address = one hop from http/non-www too;
# the old tandem-flight.html files were removed 2026-10-20 - keep these rules for old links and search results)
RewriteRule ^tandem-flight\.html$ https://www.flywithbehrooz.com/tandem-paragliding-portugal.html [R=301,L]
RewriteRule ^(pt|es|fr|de)/tandem-flight\.html$ https://www.flywithbehrooz.com/$1/tandem-paragliding-portugal.html [R=301,L]

# Redirect old tandem blog post into the merged tour page (consolidated 2026-08-27)
RewriteRule ^blog/tandem-paragliding-portugal\.html$ /tandem-paragliding-portugal.html [R=301,L]

# Redirect old sites listicle into the merged guide page (consolidated 2026-09-04)
RewriteRule ^blog/best-paragliding-sites-portugal\.html$ /blog/paragliding-portugal-guide.html [R=301,L]

# Retired ES/FR/DE Parakite Week pages (2026-09-16) — EN/PT remain
RewriteRule ^es/parakite-week\.html$ /parakite-week.html [R=301,L]
RewriteRule ^fr/parakite-week\.html$ /parakite-week.html [R=301,L]
RewriteRule ^de/parakite-week\.html$ /parakite-week.html [R=301,L]

# Redirect non-www to www
RewriteCond %{HTTP_HOST} ^flywithbehrooz\.com$ [NC]
RewriteRule ^(.*)$ https://www.flywithbehrooz.com/$1 [L,R=301]

# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Cache static assets
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png  "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
  ExpiresByType font/woff  "access plus 1 year"
  ExpiresByType text/css   "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  <Files "announce.js">
    ExpiresByType application/javascript "access plus 1 hour"
  </Files>
</IfModule>

<IfModule mod_headers.c>
  <FilesMatch "\.(jpg|jpeg|png|gif|webp|svg|ico|woff2|woff|ttf)$">
    Header set Cache-Control "max-age=31536000, public, immutable"
  </FilesMatch>
  <FilesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=2592000, public"
  </FilesMatch>
  <Files "announce.js">
    Header set Cache-Control "max-age=3600, public, must-revalidate"
  </Files>
</IfModule>

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