Please wait for 15 seconds...

Monday, 17 September 2012

In codeigniter the default URL is something like this

I will explain you here how to customise above URL in codeigniter.

Suppose you have a video hosting site and controller class named "Video" and its method named "display".

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Video extends CI_Controller {
public function display(){
// display video

To display video you have to pass video ID through URL. By default setting URL will look like this

I would recommend you to remove index.php first so URL would look like this.

Now lets jump to application/config/routes.php and open it in Notepad or Notepad++. Copy below code and paste it at the bottom of the page. Remember below code is just an example. You should use it based on your project requirement.

If video ID is an integer like 12345

$route['show/(:num)'] = "video/display/$1";

If video ID is an string like vid123

$route['show/(:any)'] = "video/display/$1";

So the new URL will be like something like this

So you can pass video ID as integer or string in both scenario it will work fine.

That it all for now see you in next tutorial.

Posted by Atul


  1. Thanks for the above information about customization url in codeigniter by giving a description and letting the customer know about the codeigniter.

    1. Thank for comment. I hope other tutorials will not disappoint you.

  2. Thanks for details about personalization url in codeigniter by providing a details and allowing the client know about the codeigniter.

  3. I wasn’t aware of some of the information that you mentioned so I want to just say thank you.

  4. I do agree with all the ideas you have presented in your post. They are very convincing and will definitely work. Thanks for the post.

  5. thanks for your help i am new on this framework and it help me very much


Techsirius on Facebook