Skip to content
Snippets Groups Projects
Commit 3964a7ad authored by enzipher's avatar enzipher
Browse files

Issue #3327905 by enzipher, agaq: Clarifying behaviour of "URL prefix redirect".

parent 7e5fad1e
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,12 @@ class HttpsWwwSettingsForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('httpswww.settings');
$host = \Drupal::request()->getHost();
$replace_args = [
'%host' => $host,
'%wwwhost' => 'www.' . $host,
];
$this->messenger()
->addWarning($this->t('Please read and understand the options before making any changes.'));
......@@ -43,9 +49,11 @@ class HttpsWwwSettingsForm extends ConfigFormBase {
<li>@line_3</li>
</ul>
', [
'@line_1' => 'Make sure your site is accessible for the options you select before enabling redirects.',
'@line_2' => 'If you don\'t have the "Bypass HTTPS and WWW Redirects" permission and are on a different domain than what you select, you will be logged out when saving.',
'@line_3' => 'Once enabled, avoid making any further changes as it may affect SEO.',
'@line_1' => $this->t('Ensure your site is accessible for the chosen options before activating redirects.'),
'@line_2' => $this->t('If you lack the %permission permission and are on a domain different from your selection, you will be logged out upon saving.', [
'%permission' => $this->t('Bypass HTTPS and WWW Redirects'),
]),
'@line_3' => $this->t('After activation, refrain from making additional modifications as it may negatively impact SEO (Search Engine Optimization).'),
]
);
......@@ -63,25 +71,21 @@ class HttpsWwwSettingsForm extends ConfigFormBase {
$form['fieldset_2'] = [
'#type' => 'fieldset',
'#title' => $this->t('URL prefix redirect'),
'#title' => $this->t('Domain WWW prefix'),
];
$fieldset_2 = new FormattableMarkup('
@line_1<br>
@line_2
', [
'@line_1' => 'Users will be redirected corresponding to the selected option.',
'@line_2' => 'Make sure your site is accessible for the option selected.',
]
);
$form['fieldset_2']['prefix'] = [
'#type' => 'radios',
'#description' => $this->t('@description', ['@description' => $fieldset_2]),
'#default_value' => $config->get('prefix') ?: 'no',
'#default_value' => $config->get('prefix') ?: 'mixed',
'#options' => [
'no' => $this->t('Without WWW prefix'),
'yes' => $this->t('With WWW prefix'),
'no' => $this->t('Remove WWW prefix'),
'yes' => $this->t('Add WWW prefix'),
],
'no' => [
'#description' => $this->t('Redirect %wwwhost to %host.', $replace_args),
],
'yes' => [
'#description' => $this->t('Redirect %host to %wwwhost.', $replace_args),
],
];
......@@ -90,23 +94,30 @@ class HttpsWwwSettingsForm extends ConfigFormBase {
'#title' => $this->t('HTTP Secure (HTTPS) redirect'),
];
$fieldset_3 = new FormattableMarkup('
$https_desc = new FormattableMarkup('
@line_1<br>
@line_2 <a href="@url" target="_blank">@url</a>
@line_2<br>
@line_3 <a href="@url" target="_blank">@url</a>
', [
'@line_1' => 'Before activating HTTPS support you must first configure your server with a valid SSL certificate.',
'@line_2' => 'For more information, see',
'@line_1' => $this->t('The site becomes accessible only via HTTPS. All HTTP requests are redirected to HTTPS.'),
'@line_2' => $this->t('ATTENTION: If you choose this option, make sure your site is accessible by HTTPS, and that your SSL certificate is valid.'),
'@line_3' => $this->t('For more information, see'),
'@url' => 'https://www.drupal.org/https-information',
]
);
$form['fieldset_3']['scheme'] = [
'#type' => 'radios',
'#description' => $this->t('@description', ['@description' => $fieldset_3]),
'#default_value' => $config->get('scheme') ?: 'mixed',
'#options' => [
'mixed' => $this->t('Enable mixed mode (both HTTP and HTTPS is allowed).'),
'https' => $this->t('Enable HTTPS and redirect all HTTP traffic (force HTTPS).'),
'mixed' => $this->t('No redirect'),
'https' => $this->t('Redirect to HTTPS'),
],
'mixed' => [
'#description' => $this->t('The site remains accessible via HTTP, as well as via HTTPS (if enabled).'),
],
'https' => [
'#description' => $this->t('@description', ['@description' => $https_desc]),
],
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment