From 58f8011657dbe78960ee8e610d03660fec63ba59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20SAILLANT?= <108685187+electron-rare@users.noreply.github.com> Date: Sat, 14 Mar 2026 17:40:50 +0000 Subject: [PATCH] Fix preview deploy without root htaccess --- docs/ovh-ftp-preview-solution-2026-03-14.md | 13 +++++++++++++ scripts/deploy-ovh-ftp-target.sh | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/docs/ovh-ftp-preview-solution-2026-03-14.md b/docs/ovh-ftp-preview-solution-2026-03-14.md index d164ead..8e81eaa 100644 --- a/docs/ovh-ftp-preview-solution-2026-03-14.md +++ b/docs/ovh-ftp-preview-solution-2026-03-14.md @@ -47,6 +47,19 @@ Fichier : Script cible : - `scripts/deploy-ovh-ftp-target.sh` +## Note preview + +Le preview ne doit pas embarquer le `.htaccess` de la racine. + +Raison : +- ce fichier contient des regles Apache pensees pour `/` +- notamment des chemins absolus comme `/index.html` et `/_astro/` +- dans `/preview`, ces regles peuvent provoquer un `403 Forbidden` + +Decision : +- la cible `preview` retire `dist/.htaccess` avant synchronisation FTP +- la cible `production` conserve le `.htaccess` pour la racine publique + ## Usage ### Preview diff --git a/scripts/deploy-ovh-ftp-target.sh b/scripts/deploy-ovh-ftp-target.sh index 56de8c0..ca44360 100644 --- a/scripts/deploy-ovh-ftp-target.sh +++ b/scripts/deploy-ovh-ftp-target.sh @@ -63,6 +63,13 @@ main() { echo "[deploy-ovh-ftp-target] Skipping build:external (already built)." fi + # The root .htaccess contains root-scoped Apache rules (`/index.html`, `/_astro/`) + # that break the preview when uploaded inside `/preview`. + if [[ "$TARGET" == "preview" && -f "${LOCAL_DIR}/.htaccess" ]]; then + echo "[deploy-ovh-ftp-target] Removing .htaccess from preview payload." + rm -f "${LOCAL_DIR}/.htaccess" + fi + bash scripts/deploy-ovh-ftp.sh "$LOCAL_DIR" }