Author Topic: How to successfully implement https [DROPLET]  (Read 122 times)

Offline crnogorac081

  • Posts: 1995
  • Gender: Male
How to successfully implement https [DROPLET]
« on: August 15, 2021, 10:28:44 AM »
Hello,

here is tutorial how to successfully implement https on your website. Today there are many ways to get free certificate and use https on your website.

So far known steps are:

In config.php instead

Code: [Select]
define('WB_URL', 'http://my-domain.com');
Change "http" to "https"
Code: [Select]
define('WB_URL', 'https://my-domain.com');

Also in .htaccess

Code: [Select]
RewriteEngine On
## Redirect from non-www to www , and change to https
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

In addition to this, make a droplet
Code: [Select]
global $wb;
$wb->preprocess($wb_page_data);
$url = WB_URL;
$url = preg_replace("(^https?://)", "", $url );
$wb_page_data = str_replace('http://'.$url, '//'.$url, $wb_page_data);
return true;

It will change all links that are manually inserted in modeules (and not via WB_URL variable) to https.

This way you will not get warning in browser warning "Conection not secure. Parts of this page are not secure (such as images)."

If there is a better way for this fell free to modify the code.



UI / UX Designer

Offline dbs

  • Betatester
  • **
  • Posts: 8667
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: How to successfully implement https [DROPLET]
« Reply #1 on: August 15, 2021, 10:34:22 AM »
Hi, this is the right way.
In the droplet or other modules you can remove the line
Code: [Select]
$wb->preprocess($wb_page_data);The line is outdated and without function.