treehouse : what would you like to learn today?
Web Design Web Development iOS Development

HTTP or HTTPS

Last updated on:

if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'
    || $_SERVER['SERVER_PORT'] == 443) {

  // HTTPS

} else {

  // HTTP

}
View Comments

Comments

  1. Permalink to comment#

    Thank you so much for this… I’ve been trying to do something similar for the last 2 weeks… can’t believe I’ve just found this now!!

Leave a Comment

Use markdown or basic HTML and be nice.