Author Archives: avenirer

How to make “truly” SEO friendly URLs in CodeIgniter (without “duplicate content” on underscore URLs)

Created at: March 23, 2016; Last update: March 24, 2016

I promised myself I won’t do anymore tutorials regarding CodeIgniter until a new version is about to appear, but I can’t help myself. And this subject seems more than appropriate for a new tutorial.

Let us start with the beginning. In routes.php (application/config/routes.php), we have a configuration parameter called “translate_uri_dashes“. If we set this parameter to TRUE, the CodeIgniter framework will translate the dashes (“-“) in our urls into underscores (“_”) when calling a controller or a method. This, of course is what we want in order to have “SEO friendly” URLs (although I think it’s strange that up until this moment, search engines can’t interpret an url). Continue reading

How to remove (redirect) trailing slashes from URLs using .htaccess

Created at: December 22, 2015; Last update: February 19, 2016

Well… I see a lot of questions regarding SEO friendly URLs, and also regarding the problem with URLs that have trailing slashes which show the same content as the URLs without trailing slashes. Although I really hope that the search engines are smarter than treating those URLs as duplicate content, I feel there is the need to know how to redirect them to the non-trailing slashes URLs.

So here it is. You open .htaccess, and you should have in it the following:

This should work for anything, not just CodeIgniter. Hope this helps…

How to create an accordion in jQuery

Created at: December 21, 2015; Last update: December 21, 2015

Well… I should start by saying that I actually hate Javascript and jQuery (sorry, guys…). If you really have to ask me why, the reason I hate it is because of the time I had the first encounter with it. It’s rather a psychological reason. The first time I took a look at Javascript was in its infancy. I was amazed at what it can do… But then I opened the same html file with another browser… it was a disaster. Then… another browser… another disaster. That is why I hate Javascript. Now someone may say that this is no longer a problem. Most browsers (if not all) are not respecting the Javascript engine directives (or whatever you call them…). But, as I said, it is a psychological hate. Continue reading

The migrations in CodeIgniter or how to have a “Git” for your database (part 3 of 3: Using Matches for faster development)

Created at: July 27, 2015; Last update: July 27, 2015

Hmm… I don’t know about you but the two tutorials before this one in the series about migration really scared me with the naming, the controllers, the format of the migration, etc. So why not speed things up? We can do this by using Matches, a CodeIgniter CLI script that helps me speed things up when talking about development in CodeIgniter. I sure hope you didn’t just realize that this is also about promoting my script (which, by the way, it’s open source…). Continue reading

The migrations in CodeIgniter or how to have a “Git” for your database (part 2 of 3: Alter tables with Migrations in CodeIgniter)

Created at: July 24, 2015; Last update: July 24, 2015

(created at: July 23, 2015; last update: July 23, 2015)
Well… you got here. So I will be assuming that you’ve already followed the first episode of this tutorial ( and all went well up until the end. If something went wrong now is the time to tell me (in a comment to to previous tutorial, please).

Now we will go a bit deeper… So… By referring to what we did in the previous tutorial (a table named “users” that has “id”, “username”, “email”, and “password” as fields), we will try to see how we can alter the table the way we want to. Continue reading

The migrations in CodeIgniter or how to have a “Git” for your database (part 1 of 3)

Created at: July 22, 2015; Last update: July 29, 2015

(created at: July 22, 2015; last update: July 29, 2015)

Well… this title is a bit misleading, isn’t it? Let’s just start by talking about what is a Git.

Git is some sort of history tracker for your code. That is, whenever you modify something in your code, Git keeps a track of how the code looked before your update, and how it looks after the update. By using it, you and those that work with you can find out how the coding evolved and return to previous versions if something went wrong or want to create a new branch.

The same happens with the migrations, these being related to the database operations. Migrations help you and your team mates keep track of the changes you make to the database tables.

So let’s get to work and see how we can use them. Continue reading

Again about my Matches CLI – a CodeIgniter CLI script

Created at: July 8, 2015; Last update: July 8, 2015

When I work on an existing CodeIgniter project, I usually just copy/paste from previous work: if I need to create a new controller, I simply copy an existing controller that looks similar to what I want to do in the new controller and paste it as the new controller. After that I delete what I don’t need (sometimes that means about 75% of the copied code). Continue reading

How to handle security in POST or GET using CodeIgniter

Created at: June 4, 2015; Last update: June 4, 2015

Well… it’s a huge subject, and I don’t know if I’m the person to ask to regarding this subject, but a reader asked me to approach it. Let’s start with mentioning the features that CodeIgniter offer in this regard. Looking at the manual, we can clearly see that it covers a lot of subjects, including session handling, encryption, security, input, and form validation. Continue reading