HTTPS

Setting Clean URL with https(SSL) for the backend and http for the front end when Drupal is in a subdirectory/ subdomain

This write up needs (technical) review. Don't just copy and paste this code unless you have at least some understanding of the matter.

In Drupal 7 in order to run https(SSL) for the admin backend and run a normal http on the front I had to do the following. This code is intented for if the backend is running on a subdomain/ subdirectory on SSL with a different URL address then the http address of the front end, and with clean URLs enabled.

In settings.php:

if ($_SERVER['SERVER_PORT'] == 443) {
$base_url = 'https://address_1.com/subdirectory';
} else {
$base_url = 'http://subdomain.address_2.com';
}

The first $base_url is the one where you have your admin backend. The second is for your website front end. What this does is when you type the address check whether we are on a https or a http connection. Then the if the address match the $base_url either become a https or a http connection and go to the $base_url that is set.

Read more

HTTPS - additional setting/modifications

The following write up should fix a couple of HTTPS issues that you might experience. These setting work along with Secure Pages.

  1. Anonymous users lose cart contents when Secure Pages switches the site from http://www.example.com to https://www.example.com
  2. When a user clicks on the Check Out button or Checkout Link on the Cart Block the page refreshes and the user is not redirected to cart/checkout

Modifying the .htaccess file

Uncomment (remove the # infront of them) these lines if you want your users to be always redirected to http://www.example.com and https://www.example.com and if you set up your SSL cert for www.example.com

#RewriteCond %{HTTP_HOST} !^www\. [NC]
#RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Uncomment (remove the # infront of them) these lines if you want your users to be always redirected to http://example.com and https://example.com and if you set up your SSL cert for example.com

# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

If after making the above changes you are still having issues try these modifications along with the above ones.

Modifying the settings.php file located in sites/default/settings.php

Read more
Subscribe with RSS Syndicate content