Skip to main content

Multiple configuration files for CodeIgniter

I recently came across a problem which is very common when deploying a web application. This time, I'm trying it with CodeIgniter. I purchased a domain and a small shared hosting to which I deploy a simple app. Along with it, I purchased the SSL so it should be accessed with https rather than http. Even all http request should be redirected to https, that's two problems.

A way to solve it is via .htaccess in the root app directory. For multi environments, we can set a CI_ENV variable via


    SetEnv CI_ENV development


So in our application/config directory we can add production directory which consist of config.php and database.php. These settings are then for production. So when we deploy the application, we need to updated those settings for production. As for me, I also have test and stage settings so I also have those directories in my config directory with config.php and database.php corresponding to that environments. This is preferred since we need to test it and put it to stage when testing is done with no issues. Stage connects to the production data but with the php files from my develop branch. In a way this tests the application with the production data. If all goes well, we can proceed to deploying to production.

Another problem is the https redirect. We can solve it with

# Uncomment these lines for https redirection
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# End http redirection

This is still in the .htaccess file. Just below the RewriteEngine on. So accessing the site via http will redirect to https.

And... we are good to go. I just couldn't find a solution for multiple .htaccess for different environments. But maybe it'll be for another post. Right now, I comment/uncomment the redirect statements when I develop locally and when I deploy it to my hosting. Anyway, I'm happy with what I have for now so yeah, if you have comments and suggestions please do comment below and I'll try to answer as best as I can.

Thanks and have a great day everyone!

Comments

Popular posts from this blog

Add Brave Browser to Netbeans

We'll I'm liking Brave now, great isn't it. With the token and all and privacy and stuff. And all the good stuff, right? So what other good thing we can do about it other than adding it to our favorite editor. So here it is, adding it is through Tools->Options->General Edit Web Browser Manager and add this setting below. Find the brave.exe usually it can be found in C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe and voila we're good. See you next posts everyone!

Monero is your friendly neighbor - no not really, I mean friendly CPU miner

Monero is another one of those crypto currency that was really big news in 2017. Now the year ends and hoping for a fresh start in 2018. Just got my masternode up and so far so good. X11 is the algo chosen by Sucre so it's not really friendly to CPU. Now, back to Monero. Its algorithm is Cryptonite and it's friendly to miners that only has CPU. First off, get your monero wallet here . As for me, I do use FreeWallet so I don't worry other app/web for every wallet that I have. Anyway, if you get your monero wallet address, that's OK. All we have to do is to find pool to mine. I use MineXMR as it's simpler. You can choose whatever you like, just search for "monero mining pools" and you get bunch to choose from. Get the miner here, extract it to your location of choice and edit the config.json file. {     "algo": "cryptonight",  // cryptonight (default) or cryptonight-lite     "av": 0,                // algorithm var...

Theory of the Genesis of Bam-e

Well, I was pondering of things today. I mean no things? Like nothing? Can't mine like shit, electricity is down almost every 2 hours so I was wondering to myself... How the hell the name "Bam-e" came to be? As a programmer I need to know the origin of it. Like learning new techniques in programming. I need to dissect things. First off, maybe it's a Tagalog term. I think so. And yeah I found it, or did I. I thought the story goes like this. Someone named Dave came to visit Bam. Here it goes... Dave: Hi, Bam ano yang ginawa mo? Bam: Nagluluto Dave: Yay, maganda yan! Masarap ba yan? Bam: Ah wala, hinalo ko lang ang mga natirang ingredients Dave: Ano name nyan? Bam: Hindi ako sure eh! Dave: Patingin nga? Bam: Sure Dave: Pancit lang naman yan Bam eh! Well, if you don't know tagalog. I'm sorry, I'm not the person to talk to. I'm Bisaya and I'm very bad at tutoring Filipino. The hell, I got 79% when I was in high school. I hate the God ...