gravatar

Codeigniter Fans : Remove index.php

Before you read this tutorial till end, please apologize me for my bad english, this is my first notes in english. I'm sorry guys.

Inspiring from railscasts.com, the Ruby on Rails Screencasts, and Nettuts, I'll try to make another tutorials by myself.

My first simple tutorials is to make a nice URL using Codeigniter, which is by default its contain index.php at URL. Such as http://example.com/index.php/articles/1.

We can remove the 'index.php' in Codeigniter by modified config file and adding some rule at .htaccess file. Config file is in config folder in application folder.

{your application name}/system/application/config/config.php

The htaccess file is in your root Codeigniter application. If you cannot find this file, it was hidden by default or maybe it is not yet created, you can created it first by create a new file using your favourite text editor, just don't add some filename, leave it blank, just add filetype .htaccess.

First, we should change the value index_page at config file to blank.

default value :
$config['index_page'] = "index.php";

change to :
$config['index_page'] = "";

And the last step is adding some rule in htaccess file.

RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /{your application name}/index.php/$1 [L]

That's all for this sections, see you in the next tutorials. Hope this will help you.

wallohu'alambishowab

gravatar

ngak bisa bos...ane pake ci 1.7.2..