# Harvey Monster Team — Apache (shared hosting)
# Положить в корень сайта рядом с index.html. Требуется mod_rewrite (есть на любом shared-хостинге).

Options -Indexes
DirectoryIndex index.html
AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>
  RewriteEngine On

  # 1. Всегда HTTPS (иначе Яндекс.Директ и Метрика видят два разных сайта).
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # 2. Один канонический хост: www → без www (совпадает с canonical в index.html).
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
</IfModule>

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

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/html                 "access plus 0 seconds"
  ExpiresByType application/json          "access plus 0 seconds"
  # JS/CSS без хэша в имени: длинный кэш оставил бы у посетителей старую версию после деплоя.
  ExpiresByType text/css                  "access plus 1 day"
  ExpiresByType application/javascript    "access plus 1 day"
  ExpiresByType image/webp                "access plus 1 year"
  ExpiresByType image/png                 "access plus 1 year"
  ExpiresByType image/jpeg                "access plus 1 year"
  ExpiresByType image/svg+xml             "access plus 1 year"
  ExpiresByType font/woff2                "access plus 1 year"
</IfModule>

<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
  # Кэш HTML отключён: правки на сайте видны сразу после загрузки, без Ctrl+Shift+R.
  <FilesMatch "\.html$">
    Header set Cache-Control "no-cache, must-revalidate"
  </FilesMatch>
</IfModule>
