Fix https detection

Based on CodeIgniter issue #2508
https://github.com/EllisLab/CodeIgniter/issues/2508

Specifically, changing https detection to:
! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'

I did not include the files mentioned in the issue, since they are
CodeIgniter files  (though I updated them for my site). It might be
worthwhile to update the files, though, since I'm not sure when or if
the 2.1 branch will be updated on their end.