.htaccess (1)

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