From 6e8b8befe60cceb4cbf8d0e256c6a7d3eaf8ae63 Mon Sep 17 00:00:00 2001 From: popovskik Date: Sun, 2 Aug 2026 12:26:27 +0200 Subject: [PATCH] Add .htaccess: branded 404, compression, caching, MIME types Appends static-site production defaults below the existing root->/en/ redirect: ErrorDocument 404 /404.html, gzip compression, browser caching (short for CSS/JS since unhashed, longer for images/fonts), correct WebP/ SVG/manifest MIME types, -Indexes, and X-Content-Type-Options. All guarded by so a missing module cannot 500; ignored by nginx. Co-Authored-By: Claude Opus 4.8 (1M context) --- .htaccess | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/.htaccess b/.htaccess index ec6924b2..7d74951a 100644 --- a/.htaccess +++ b/.htaccess @@ -4,3 +4,55 @@ RewriteCond %{HTTP_HOST} ^msos\.spletnimojster\.si$ [OR] RewriteCond %{HTTP_HOST} ^www\.msos\.spletnimojster\.si$ RewriteRule ^/?$ "https\:\/\/msos\.spletnimojster\.si\/en\/" [R=301,L] + +# ============================================================ +# Static-site defaults (added for SEO / performance / 404). +# Wrapped in guards so a missing module can't 500. +# Ignored by nginx (harmless). No extra HTTPS/host redirects — +# the host handles TLS and the rule above handles the root. +# ============================================================ + +# ----- Custom branded error page ----- +ErrorDocument 404 /404.html + +# ----- Don't expose directory listings ----- +Options -Indexes + +# ----- Correct MIME types (WebP, SVG, manifest, fonts) ----- + + AddType image/webp .webp + AddType image/svg+xml .svg + AddType application/manifest+json .webmanifest + AddType image/x-icon .ico + AddType font/woff2 .woff2 + + +# ----- Gzip / compression for text assets ----- + + AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml + AddOutputFilterByType DEFLATE application/javascript application/json + AddOutputFilterByType DEFLATE application/xml application/manifest+json + AddOutputFilterByType DEFLATE image/svg+xml + + +# ----- Browser caching ----- +# No file-hashing on this site, so keep CSS/JS short (updates must propagate) +# and cache images/fonts longer. HTML is always revalidated. + + ExpiresActive On + ExpiresByType text/html "access plus 0 seconds" + ExpiresByType text/css "access plus 1 day" + ExpiresByType application/javascript "access plus 1 day" + ExpiresByType image/webp "access plus 1 month" + ExpiresByType image/jpeg "access plus 1 month" + ExpiresByType image/png "access plus 1 month" + ExpiresByType image/svg+xml "access plus 1 month" + ExpiresByType image/x-icon "access plus 1 month" + ExpiresByType font/woff2 "access plus 1 month" + + + Header set X-Content-Type-Options "nosniff" + + Header set Cache-Control "no-cache, must-revalidate" + +