# Macropus Peptides: Spaceship (Apache / LiteSpeed) settings
DirectoryIndex index.html
ErrorDocument 404 /404.html
Options -Indexes
DirectorySlash On

RewriteEngine On

# One address for the whole site: https://macropuspeptides.com (no www).
# www and http requests are sent there with a single permanent (301) redirect.
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://macropuspeptides.com%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://macropuspeptides.com%{REQUEST_URI} [L,R=301,NE]

# /page/index.html and /index.html -> the clean folder address
RewriteCond %{THE_REQUEST} \s/+((?:[^\s?]*/)?)index\.html[\s?] [NC]
RewriteRule ^ /%1 [L,R=301,NE]

# File types
AddType image/webp .webp
AddType image/svg+xml .svg
AddType text/javascript .js
AddType application/json .json
AddDefaultCharset utf-8

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

# Caching. Scripts and page data carry a version number (?v=...), so they can be cached for a year;
# every build changes the number. Pages are always revalidated so updates show at once.
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/webp "access plus 30 days"
  ExpiresByType image/png "access plus 30 days"
  ExpiresByType image/jpeg "access plus 30 days"
  ExpiresByType image/svg+xml "access plus 30 days"
  ExpiresByType text/javascript "access plus 1 year"
  ExpiresByType application/json "access plus 1 year"
  ExpiresByType text/html "access plus 0 seconds"
</IfModule>
<IfModule mod_headers.c>
  <FilesMatch "\.(js|json)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  <FilesMatch "\.html$">
    Header set Cache-Control "no-cache"
  </FilesMatch>
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
  Header always set Strict-Transport-Security "max-age=31536000"
</IfModule>

# Never serve hidden files
<FilesMatch "^\.">
  Require all denied
</FilesMatch>
