Codeigniter (2)

How to get a non-Latin slug from the address bar

By: Hossein Jalali • December 15, 2013

Sometimes when creating websites in Arabic or Farsi we are forced to accept slugs* that are non-Latin, These links usually look nice on the address bar but that is the only place they look good. Once we copy paste that URL and pass it on to others each character turns into a strange ASCII unit. 

Now that can also be acceptable if we were not going to use the slug, but in cases where we use that slug as an identifier for the article, news, or whatever it is associated with, then we have a problem. The problem is that our database has saved the slug in it's non-Latin form while when storing the slug as a variable it dispaly incorrectly.

This is where two lines of code comes in handy.

Read More

The best .htaccess code for CodeIgniter

By: Hossein Jalali • December 2, 2013

After long amount of searching and usually finding available .htaccess files that do not work, I have finally assembled the best .htaccess for codeigniter. This file serves 4 very important needs:

  • Access to important folders: I need to access my images, css, js folders. One line of code on the .htaccess fixes that problem easily.
  • Adding www. to non www. URL's: Another important SEO problem is distinguishing between a URL that has www. at the beginning and one that does not. Search Engines find these as two different links and this could cause SEO problems. With our .htaccess we have resolved that problem.
  • Removal of trailing backslash: Anyone who tries the slightest to make their website more SEO friendly than others has at some point reached this pesky problem of trailing backslashes. Our code fixes the problem with a simple 301 redirect to the no backslash version.
  • IP Canonicalization: Google by default will see your IP address as a second website and in this case will consider a duplicate of your domain. To fix that you must do a 301 redirect from the IP to the actual domain name.
  • Removal of the index.php file: With our .htaccess you can easily have the index.php removed from the end of your domain. Just rememebr to delete the index.php in the config.php as well.

Read below to get access to the file.

Read More