Reroute Drupal 9 site from http to https using the .htaccess file
Tuesday, December 22, 2020
Go to the root directory of Drupal 9 site and change the write permission of the .htaccess
file to write enable.sudo chmod 777 .htaccess
Open .htaccess
with nano
commandsudo nano .htaccess
Insert the following lines:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:jhun\.verterra\.me)?(.*)$ [NC]
RewriteRule (.*) https://jhun.verterra.me%1%{REQUEST_URI} [L,R=301]
The above insertion is best placed below the redirection from WWW to without WWW.
Exit from nano and save the .htaccess file
Revert the permissionsudo chmod 644 .htaccess
Go to your browser and check if redirection from http to https works. You may need to flush all cache.
Category
Comments