Site icon Osclass Documentation & Knowledge Base

SSL certificate configuration (https)

There are 3 steps you should do to correctly setup SSL certificate on your Osclass installation.

Create or activate SSL certificate

Very first step is to activate SSL certificate on your site. Make sure certificate is valid and functional, otherwise all assets on your website (css, js, img, …)

Update website URL in config.php to use https

Go to file config.php located in root directory of your Osclass installation.

Update constant WEB_PATH and make sure it use https:// instead of http://. Example

define('WEB_PATH', 'https://yoursite.com/');

Create redirect in .htaccess file (optional)

This step is optional, because it can also be defined from hosting settings (or i.e. cloudflare settings) to force https connection.

Anyway, objective is to redirect all cached URLs (i.e. in user browsers, search engines, …) to use safe version of your site that use https protocol.

There are multiple alternatives and tutorials you may use to setup redirect in htaccess.

Now, go to file .htaccess located in root Osclass installation directory (it may not be visible, or may not exists yet. If it does not exists, create blank one) and place to file following code (select your alternative):

Alternative #1:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[L,R=301]
</IfModule>


Alternative #2 (redirect all web traffic):

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]


Alternative #3 (redirect only specific domain):

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]


Alternative #4 (redirect only specific folder):

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.yourdomain.com/folder/$1 [R,L]

That’s it, test your site and make sure everything works as expected!

Troubleshooting – common problems

Config.php not updated with correct protocol – you’ve setup SSL, setup redirect (in .htaccess file or via hosting tools) but forgot to update config.php. What it means is, that links to your images, stylesheets and javascript files will have “http://” in source code, but your site will run on “https://” already, means all assets will not be loaded!

Config.php updated, but certificate is invalid – you’ve updated protocol in config.php to “https://” but SSL certificate is not yet ready. Osclass will update all assets links to use “https://”, but if SSL cerftificate is not valid, content will not be loaded!