Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do I have to code to use HTTPS?

Tags:

php

https

Within a standard "brochure" site I have a subsystem where private data is passed back and forth in a series of pages. The site is done and working now without HTTPS.

Can someone point me to a list of steps that I need to do, to implement HTTPS on the secure part of the site?

like image 304
sdfor Avatar asked Oct 05 '10 15:10

sdfor


1 Answers

The only thing you as a programmer need to do is checking that the user in fact uses HTTPS:

if($_SERVER['SERVER_PORT'] !== 443 &&
   (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off')) {
  header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
  exit;
}

Then (have your sysadmin) order and install a SSL certificate on the web server.

like image 192
Emil Vikström Avatar answered Nov 01 '22 04:11

Emil Vikström