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 <IfModule> so a missing module cannot 500; ignored by nginx. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
314667f692
commit
6e8b8befe6
52
.htaccess
52
.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 <IfModule> 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) -----
|
||||
<IfModule mod_mime.c>
|
||||
AddType image/webp .webp
|
||||
AddType image/svg+xml .svg
|
||||
AddType application/manifest+json .webmanifest
|
||||
AddType image/x-icon .ico
|
||||
AddType font/woff2 .woff2
|
||||
</IfModule>
|
||||
|
||||
# ----- Gzip / compression for text assets -----
|
||||
<IfModule mod_deflate.c>
|
||||
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
|
||||
</IfModule>
|
||||
|
||||
# ----- 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.
|
||||
<IfModule mod_expires.c>
|
||||
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"
|
||||
</IfModule>
|
||||
<IfModule mod_headers.c>
|
||||
Header set X-Content-Type-Options "nosniff"
|
||||
<FilesMatch "\.html$">
|
||||
Header set Cache-Control "no-cache, must-revalidate"
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
|
|
|
|||
Loading…
Reference in New Issue