PHP redirect from http to https and www to non-www in Drupal 9
settings.php
Go to sites/default/settings.php
add the following lines in the top of the file below <?php
if ( (!array_key_exists('HTTPS', $_SERVER)) && (PHP_SAPI !== 'cli') ) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://eduvai.com'. $_SERVER['REQUEST_URI']);
exit();
}
// Remove www
if ($_SERVER['HTTP_HOST'] == 'www.eduvai.com') {
header('HTTP/1.0 301 Moved Permanently');
header('Location: https://eduvai.com'. $_SERVER['REQUEST_URI']);
exit();
}
Comments
Post a Comment