Monthly Archives: December 2015

Trials and Tribulations

Redirect http to https for a domain in Plesk 12.5

It’s a good evolution that it keeps on getting easier to add a SSL certificate to a domain. And I would certainly encourage to do so, if you have the chance. For example, when you’re using Parallel’s/Odin’s Plesk as a hosting environment it is really easy to import a SSL certificate for a specific domain.

But the thing that is not so straightforward is forcing a domain to only run https.

This is because, remarkably, there is no native setting or magic checkbox you can select to make this happen. In fact, there is currently no other way then to add a custom directive to the .htaccess or vshost configuration of the domain. So, let’s clear things up and simply make it easy, using the following instructions (applicable to the Linux variant of Plesk 12.5 only):

First, login to your Plesk instance and navigate to the appropriate domain settings. In here, select the Apache & nginx settings, which is a new option in Plesk 12.5.

plesk_control_panel

On the settings page you’ll find the options to add Additional Directives for both http and https. The only thing we’re interested right now is simply redirecting all traffic from http to https. For this, we’ll simply add a rewrite rule to the http directive:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,QSA]
</IfModule>

Which will look like:

plesk_apache_nginx_settings

Hit the Apply button and all your traffic will be automatically rewritten to use https.