$this->addField('seo', BunchOfFieldsMultiple::class, '', ['translatable' => true, 'edit_label' => '%url | %seo_title', 'allows_add' => false, 'allows_delete' => false, 'allows_clone' => false, 'allows_reorder' => false, 'bunch' => SEOPage::class, 'tab' => __('SEO')]);
$this->addField('former_sitemap', Code::class, __('Ancienne sitemap'), ['language' => 'xml', 'tab' => __('Redirections')]);
$this->addField('redirections', BunchOfFieldsMultiple::class, '', ['translatable' => false, 'edit_label' => '%from → %to', 'bunch' => Redirection::class, 'tab' => __('Redirections')]);
+ $this->addField('force_https', Checkbox::class, __('Forcer HTTPS'), ['hint' => __('Décocher lorsque le site est installé derrière un proxy prenant en charge le certificat SSL'), 'default' => true, 'tab' => __('Redirections')]);
$this->addField('api', Hidden::class);
}
$htaccess = '<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
+ ';
+ if($this->force_https){
+ $htaccess.='
+ RewriteCond %{HTTPS} off
+ RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=308,L]
+ ';
+ }
+
+ $htaccess.='
RewriteCond %{HTTP_HOST} !=' . $domain . '
RewriteRule ^(.*)$ https://' . $domain . '/$1 [R=301,L]
{
-
$urlmaps = $this->getURLMaps();
$urlmap = $urlmaps[$locale];
$origRelative = $relative;
}
-
// Replace URL
foreach ($urlmap as $k => $v) {
$html = str_replace(ltrim($k, '/'), ltrim($v, '/'), $html);
$localeURL .= "</script>";
}
- $html = str_replace('</head>', '<link href="/css/custom.css" rel="stylesheet">' ."\n". '</head>', $html);
+ $html = str_replace('</head>', '<link href="/css/custom.css" rel="stylesheet">' . "\n" . '</head>', $html);
$html = str_replace('</body>', $localeURL . '<script src="/js/custom.js"></script>' . "\n" . '</body>', $html);
-
$html = preg_replace('/\s+lang="[a-zA-Z\-_]{2,6}"/', ' lang="' . $locale . '"', $html);
// Images
-
// SEO
if (!$isMainLocale || $htmlPage) {
foreach ($seo as $s) {