Force HTTPS from the admin, with a probe before and after

System > HTTPS and cms:https switch the redirect lines in public/.htaccess
only when the site answers over HTTPS, and take them back on a loop. HSTS
is a separate second switch. The redirect block moves before the front
controller rules, where it never reached pages, and .well-known is no
longer denied, so the origin probe works on Apache. The Git updater keeps
switched-on lines like the archive update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kantarciandClaude Opus 5.5 committed 2026-10-12 17:22:56 +02:00
1 parent daad5a1740
commit 8b212d5cc9
15 files changed
+614 -24

No files matched your search

+1 -9
View File
@@ -566,15 +566,7 @@ final class ArchiveUpdate
*/
private function mergeHtaccess(string $neu, string $alt): void
{
$vorher = (string) file_get_contents($alt);
$inhalt = (string) file_get_contents($neu);
foreach (['RewriteCond %{HTTPS} !=on', 'RewriteCond %{HTTP:X-Forwarded-Proto} !=https', 'RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]', 'Header always set Strict-Transport-Security'] as $zeile) {
$aktiv = 1 === preg_match('/^\s*'.preg_quote($zeile, '/').'/m', $vorher);
if ($aktiv) {
$inhalt = (string) preg_replace('/^(\s*)#\s*('.preg_quote($zeile, '/').')/m', '$1$2', $inhalt);
}
}
file_put_contents($alt, $inhalt);
file_put_contents($alt, HttpsRedirect::keepEnabled((string) file_get_contents($neu), (string) file_get_contents($alt)));
}
/**