HifiPlanet-Website/hifi/.htaccess
Maaxxs 54928d1411 Add package badges/visibility and a download area, speed up the site
Customer feedback round (4 items):

- Packages: one-click "Sichtbar/Ausgeblendet" toggle per package (saved
  immediately). Hidden packages disappear from the model page; the tier
  look of the remaining cards is ranked across all packages so it stays
  stable.
- Packages: badge per card (Empfohlen, Am beliebtesten, Tipp, Coming soon
  or custom text) plus an optional video link shown as "Zum Video". Legacy
  is_featured maps to "Empfohlen".
- New download area (/downloads + Admin -> Downloads): upload with
  progress, inline audio player, allow-listed file types, optional access
  password, new permission downloads.manage. Files live in
  api/uploads/downloads/ (gitignored, created at runtime).
- Performance:
  - SetupGate no longer refetches and remounts the whole app on every
    navigation.
  - Page loader waits only for pending API calls and above-the-fold images
    (fixes an 8 s hang on /leistungen caused by lazy images inside the
    hidden container).
  - Admin pages lazy-loaded; icon library moved out of the main bundle
    (initial JS 2.2 MB -> 0.48 MB).
  - Background video loads only near the viewport and was re-encoded to
    720p (32 MB -> 8.5 MB).
  - Visitors without a session cookie get no PHP session, so their parallel
    API requests no longer queue on the session lock.
  - index.html is served with Cache-Control: no-cache so browsers don't
    keep a stale build after deploys.
- Fonts (Barlow, Barlow Condensed, Michroma) are self-hosted instead of
  loaded from Google Fonts; the default privacy policy mentions this, lists
  all local storage uses and uses the new TDDDG name.
- A code update that adds a table no longer sends the site into the setup
  wizard while an admin exists.

Run "Datenbankstruktur aktualisieren" after deploying (new package
columns, downloads table, app_settings.downloads_password).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 23:15:48 +02:00

71 lines
3 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>
# Gegenstueck: index.html (verweist auf die gehashten Dateien oben) muss der Browser bei
# jedem Aufruf kurz beim Server nachfragen (meist nur ein 304 ohne Inhalt). Ohne Angabe
# behalten Browser sie per Heuristik tagelang - nach einem Deploy laedt ein wiederkehrender
# Besucher dann noch die alte Seite samt inzwischen geloeschter Skripte (weisse Seite).
<FilesMatch "\.html$">
Header set Cache-Control "no-cache"
</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
# Groessere Upload-/POST-Limits fuer den Daten-Export/-Import im Admin-Bereich
# (der Export bettet die Bildergalerie als Base64 direkt in die JSON-Datei ein,
# das kann schnell 40+ MB werden - PHPs Standard-Limits liegen oft niedriger).
# Nur relevant, wenn PHP als Apache-Modul laeuft (mod_php) - die IfModule-Pruefung
# sorgt dafuer, dass dieser Block auf FastCGI/PHP-FPM-Hosting (dort greift
# stattdessen api/public/.user.ini) folgenlos uebersprungen wird, statt einen
# "Invalid command"-Fehler fuer die ganze Seite auszuloesen.
<IfModule mod_php.c>
php_value upload_max_filesize 200M
php_value post_max_size 200M
php_value memory_limit 512M
</IfModule>
<IfModule php_module>
php_value upload_max_filesize 200M
php_value post_max_size 200M
php_value memory_limit 512M
</IfModule>
<IfModule php7_module>
php_value upload_max_filesize 200M
php_value post_max_size 200M
php_value memory_limit 512M
</IfModule>
<IfModule php8_module>
php_value upload_max_filesize 200M
php_value post_max_size 200M
php_value memory_limit 512M
</IfModule>
# 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]