How to serve a domain only through HTTPS or HTTP

From HTTP to HTTPS

In order to serve a domain only through the HTTPS protocol, we must follow these steps:

Required data

  • domain = domain name

Sample data

Process

1. Append the next string to the .htaccess file

   # Redirect to HTTPS
   RewriteCond %{HTTPS} off
   RewriteCond %{HTTP:X-Forwarded-Proto} !https
   RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

2. Make sure that the setting.php (sites/default/setting.php) file is compatible with the change (https)

$base_url = 'https://www.gafoac.com';

From HTTPS to HTTP

In order to serve a domain only through the HTTP protocol, we must follow these steps:

Required data

  • domain = domain name

Sample data

Process

1. Append the next string to the .htaccess file

   # Redirect to HTTP
   RewriteCond %{HTTPS} on
   RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

2. Make sure that the setting.php (sites/default/setting.php) file is compatible with the change (http)

$base_url = 'http://www.gafoac.com';

Reference