I recently built a shopping cart for a client using ExpressionEngine and had to make the checkout secured by SSL. Once the SSL certificate is installed, the trick is to make every link on the page have a https:// or // protocol. I was using structure and a few other plugins, so the task seemed a bit daunting. It turned out to be really simple.

1) In the htaccess file you need to force certain pages to be https. This code will do that...

# Force HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /account/checkout/
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]

2) Next, convert any google fonts links to start with // and any others you can find that are hard coded.

3) Lastly, in order to have all your addons output the proper protocol add this code to your index.php file so that it sets the site_url variable to https if that is the protocol being used.

if(strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https') // site_url is https if its in the url
$assign_to_config['site_url'] = 'https://'.$_SERVER['HTTP_HOST'].'/';

Too easy? I know, I told you so!

« Back to Main