http to https |
I know CI4 is not quite production ready and I also know that when on a live site settings should be to "production" however I have a development domain and hosting site and i have time on my hands now, which i might not get later.
I have got the basics of a generic web set up using CI4 at : http://www.benxmidia.com (midia is deliberately spelt wrong before someone mentions it ) All the basics are working : bootstrap4 & breakpoints contact form to my email and a light CMS feature and login a basic captcha now i now want to try to shift from http to https On my hosting via cpanel there is a "lets encrypt" functionality. Now in the docs i did see that in a controller i could use https_force(0 in a controller. Can someone elaborate on steps to get CI4 to work with https on the basis that I have set up "lets encrypt"
CI 4 are declared stable, and are now on 4.0.2. With lots of development being done behind the scene.
Open up your /public/.htaccess and change Line 26 Code: RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L] You will also need to change your app.baseURL to https: https://codeigniter4.github.io/userguide...ion-set-up I think you are referring to the following in the app/config/App.php. Personally I like to do all redirects on server level, as it will give you best performance. If it can't be done, an option have been provided, with said config. Code: public $forceGlobalSecureRequests = false; If you want to add HSTS as CI4 does, you need to add the following to your .htaccess. https://en.wikipedia.org/wiki/HTTP_Stric...t_Security Code: <IfModule mod_headers.c>
Changing the .htaccess are what I mean by server level in this regard. Sorry for the confusion.
(03-16-2020, 01:38 PM)jreklund Wrote: Changing the .htaccess are what I mean by server level in this regard. Sorry for the confusion. yes think i got it ; the .htaccess in public change: RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] to RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L] however i had a problem on development with htaccess that csme with CI4 ; i'm running slackeware linux and using virtual host. The .htaccess that came with codeigniter didn't work this one is the one i'm using which works on localhost dev and Ci4 that i have live : Code: # Use the front controller as index file. It serves as a fallback solution when
i replaced my .httaccess to one from a new download of CI4 and strangely it all worked.
I changed public $baseURL = 'http://127.0.0.2'; //thats my localhost to : $baseURL= 'https://www.benxmidia.com/'; //my live domain I then from cpanel installed "letsencrypt" ; i went to edit .httacess and noted letsencypt has over written it. https now seems to be working though at https://www.benxmidia.com
Great that you got it all sorted out. Maybe letsencrypt failed to auto patch it before.
|
Welcome Guest, Not a member yet? Register Sign In |