HifiPlanet-Website/hifi/.htaccess
Maaxxs ec84b438ca PageSpeed/Lighthouse fixes: caching, images, touch targets, console noise
Based on a Lighthouse audit of the live site (95 performance / 91
accessibility / 96 best-practices / 100 SEO), addressing everything
except the flagged color-contrast issues (kept as-is, reversible
color changes need a separate decision):

- Cache-Control headers for hashed/immutable static assets via
  mod_headers (no mod_expires dependency, since that's not enabled
  everywhere) - ~1.1MB saved on repeat visits
- Converted the code-bundled homepage photos to WebP (skipped
  DB-managed/admin-uploaded images - those are content, not code) and
  added explicit width/height so the browser can reserve space before
  images load
- Bumped footer/contact-sidebar phone and email links to a 24px+
  touch target via padding
- /auth/me now returns 200 + {authenticated:false} instead of 401 for
  logged-out visitors - it's called on every public page load to
  check session state, so "not logged in" is the normal case, not an
  error; the 401 was showing up as a console error on literally every
  page view

Left unchanged: the lucide-react bundle splitting (a previous,
deliberate tradeoff - splitting per-icon created ~1600 tiny chunk
files that failed to upload on shared hosting) and video preload
(no concrete issue found in the audit).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-07 02:40:57 +02:00

36 lines
1.5 KiB
ApacheConf

RewriteEngine On
RewriteBase /
# Lang-lebiger Cache fuer gehashte Build-Assets (Vite haengt bei jeder Aenderung einen
# neuen Hash an den Dateinamen) und hochgeladene Bilder (bekommen beim Upload einen
# zufaelligen Dateinamen) - beide aendern sich unter derselben URL nie, "immutable" ist
# hier also sicher. Ueber mod_headers statt mod_expires, da Letzteres nicht ueberall
# aktiviert ist.
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|woff2?|ttf|eot)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
<FilesMatch "\.(jpg|jpeg|png|webp|avif|gif|svg|ico|mp4|webm)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
</IfModule>
# Ohne dies leitet Apache (mod_dir) Anfragen an /api/uploads mit einem 301 auf
# /api/uploads/ um, bevor mod_rewrite greifen kann - weil api/uploads/ als
# echtes Verzeichnis existiert. Bei einem POST mit Datei-Upload geht dabei der
# Body verloren (der Browser sendet den redirect als GET nach), wodurch der
# Upload mit "Methode nicht erlaubt" fehlschlägt.
DirectorySlash Off
# API-Requests an den PHP-Front-Controller weiterleiten
RewriteCond %{REQUEST_URI} ^/api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/(.*)$ api/public/index.php [QSA,L]
# Dynamische sitemap.xml (DB-generiert)
RewriteRule ^sitemap\.xml$ api/public/sitemap.php [L]
# Alles andere: SPA-Fallback auf index.html (React Router übernimmt das Routing)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [QSA,L]