Forum

Thread tagged as: Question, Configuration, Hosting

Using SSL Certificate / redirect to https

Hi,

I want a site using the SSL certificate, so it need to run on https instead of http. Is it enough to add <?php PerchSystem::force_ssl(); ?> to the homepage? Or are more actions/configuration needed? It's a single page website.

The SSL certificate is activated for this domain.

It's been a long time that I've done a Perch website, so I'm a bit out of it. Hope you can help me with!

Thx!

Wouter

The Homepage template (first part only):

<?php include('perch/runtime.php');?>
<?php PerchSystem::force_ssl(); ?>
<!doctype html>
<head>
<title><?php perch_content('Website titel'); ?></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
etc...

The Diagnostic Report:

HEALTH CHECK
PHP 5.6.34-1+0~20180306104659.10+stretch~1.gbpcf9482 is up to date
MySQL 5.5.5-10.1.26-MariaDB-0+deb9u1 is up to date
Image processing available
SUMMARY INFORMATION
Perch: 2.8.34, PHP: 5.6.34-1+0~20180306104659.10+stretch~1.gbpcf9482, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34)
App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/nwhs.nl/public_html/perch
PERCH_CORE: /home/nwhs.nl/public_html/perch/core
PERCH_RESFILEPATH: /home/nwhs.nl/public_html/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 16M, Max POST 16M, Memory: 128M, Total max file upload: 16M
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
Resource folder writeable: Yes
HTTP_HOST: nwhs.nl
DOCUMENT_ROOT: /home/nwhs.nl/public_html
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Wouter van der Zee

Wouter van der Zee 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

PerchSystem::force_ssl(); was for mixed environments - you shouldn't use it these days. You need to configure SSL at your web server, not in the CMS.

You should probably also add the following to your config.php:

define('PERCH_SSL', true);

https://docs.grabaperch.com/perch/configuration/ssl/

Drew McLellan said:

PerchSystem::force_ssl(); was for mixed environments - you shouldn't use it these days. You need to configure SSL at your web server, not in the CMS.

Ah ok, so just a redirect in my .htaccess would be sufficient?

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hi Wouter

so just a redirect in my .htaccess would be sufficient?

Yes, you can force HTTPS with something like this:

# Force https
RewriteCond %{HTTPS} !on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

You can test your rules with this tool: https://htaccess.mwl.be/

Yep, thx! Founded also something like that. Good to know that Perch itself doesn't need to be adjusted for HTTPS.