CodeIgniter Forums
CodeIgniter-SSLHook - Appropriate headers and redirection for SSL websites - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: CodeIgniter-SSLHook - Appropriate headers and redirection for SSL websites (/showthread.php?tid=70472)



CodeIgniter-SSLHook - Appropriate headers and redirection for SSL websites - mehdibo - 04-13-2018

This hook will force users to use your HTTPS version of the website, it will also set some extra headers.

More details here:
https://github.com/mehdibo/Codeigniter-SSLHook


RE: CodeIgniter-SSLHook - Appropriate headers and redirection for SSL websites - skunkbad - 04-13-2018

It's my opinion that the application layer is the wrong time to redirect users to HTTPS. Apache makes it extremely easy to do this kind of redirect:

Either this:

Code:
RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

or I'd usually use this:


Code:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]



RE: CodeIgniter-SSLHook - Appropriate headers and redirection for SSL websites - mehdibo - 04-14-2018

(04-13-2018, 05:22 PM)skunkbad Wrote: It's my opinion that the application layer is the wrong time to redirect users to HTTPS. Apache makes it extremely easy to do this kind of redirect:

Either this:

Code:
RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

or I'd usually use this:


Code:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

I agree actually, it'll be faster if you redirect using .htaccess and even the headers can be set there but... I already made it ¯\_(ツ)_/¯