Setting Up SSL For Drupal Sites on OIT Web Hosting

Drupal Version
Tags

Editor's Note: Information on Obtaining and SSL Certificate and Setting Up SSL on OIT Web Hosting with an External Domain Name has been moved to the Georgia Tech Resources for Webmasters website.

Additional details about enabling SSL for Drupal can be found in Jimmy Kriigel's posting in GitHub about SSL and Drupal sites.

Part I: SSL Certificate

See if you need an SSL Certificate, and if so, obtain your SSL Certificate

Part II: Configure Your Drupal Instance

Edit Your Site's .htaccess File

Add the following directly after "RewriteEngine On" in your site's .htaccess file:

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

Edit Your Site's settings.php File

Find the line for "$base_url" (or add one if this setting is not defined), and set it to the the fully qualified domain name of your site, like so:

$base_url = "https://foobar.gatech.edu/";

Important Note:  The settings.php file is usually protected from editing, so you may have to modify its access permissions before you can modify it.  Try editing it from the File Manager in your hosting account's Plesk Control Panel, as this may make it easier to override those protections.

Move or Symlink Your Site to /httpsdocs

Read the Enable SSL for your OIT Hosting Account post to see what kind of hosting account you have.  If you have a new-style account with only a /httpdocs/ directory, then all you need to do is add the following to your .htaccess directly below the lines you added in the "Edit Your Site's .htaccess File" section above:

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

If you have an old-style account with both /httpdocs/ and /httpsdocs/ directories, you'll need to do one of the following:

  1. If your Drupal site is not managed by Installatron, you can just move everything from /httpdocs/ to /httpsdocs/, then create a .htaccess file in your /httpdocs/ directory with the following in it:

    Redirect / <YOUR-SITE-DOMAIN-NAME-HERE>/ 301

  2. If your Drupal site is managed by Installatron, then you don't want to move it (unless you're comfortable with taking it out of Installatron first, then re-adding it to Installatron after the move.) In this case, you can take a different approach of symlinking /httpsdocs/ to /httpdocs/.

    1. Remove the /httpsdocs/ directory completely (you should be able to do this now under the current release of the Plesk Control Panel system.

    2. Create the symlink of /httpsdocs/ to /httpdocs/, either through the File Manager in the Control panel, or if using SSH:

      $ cd /
      $ ln -s httpdocs httpsdocs

    3. Add the following to your .htaccess directly below the lines you added in the "Edit Your Site's .htaccess File" section above:

      RewriteCond %{HTTPS} !=on
      RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]