Force HTTPS with Zend Framework 2

Note: This article was originally written on Reich Web Consulting has narrowed its focus to the web and no longer offers tech support services, so we’ve moved all of our tech support content off-site. We hope you find this article useful. It is provided as-is, and we will no longer provide support on this topic.

My latest project authenticates my user’s using their Active Directory credentials, I didn’t want them submitting their username and password through an unencrypted connection. I’m just learning Zend Framework, but the simplest solution to this problem seemed to be to create a reusable module that would automatically force all communication through an HTTPS connection. I adapted the code from this submission on GitHub, removed a bunch of unnecessary code. You can copy and paste this module into any ZFW 2.0 project, just remember to enable it in your application.config.php.

    Reich Web Consulting

    Written by

    Purveyor of fine web creations. Former tech support geniuses. Occasional spouter of opinions on topics of politics and ethics.