CodeIgniter Forums
Best way to automatically force https - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Best way to automatically force https (/showthread.php?tid=81335)



Best way to automatically force https - geekita - 02-17-2022

Hi! What would be the best way to automatically force https redirection with CI4?


RE: Best way to automatically force https - kilishan - 02-17-2022

In app/Config/App.php there's a flag for that.

PHP Code:
/**
     * --------------------------------------------------------------------------
     * URI PROTOCOL
     * --------------------------------------------------------------------------
     *
     * If true, this will force every request made to this application to be
     * made via a secure connection (HTTPS). If the incoming request is not
     * secure, the user will be redirected to a secure version of the page
     * and the HTTP Strict Transport Security header will be set.
     *
     * @var bool
     */
    
public $forceGlobalSecureRequests false

You could also set it in your Apache/Nginx/etc configuration, so whichever works best for you.


RE: Best way to automatically force https - geekita - 02-17-2022

Oh gosh! Didn't spot it in the docs. Thanks a lot!