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".
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.
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.
http://www.mygreatsite.com/index.php/video/display/12345
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
}
}
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
http://www.mygreatsite.com/index.php/video/display/video_id
I would recommend you to remove index.php first so URL would look like this.
http://www.mygreatsite.com/video/display/video_id
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
http://www.mygreatsite.com/show/vid123
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.
Thanks for the above information about customization url in codeigniter by giving a description and letting the customer know about the codeigniter.
ReplyDeleteThank for comment. I hope other tutorials will not disappoint you.
DeleteThanks for details about personalization url in codeigniter by providing a details and allowing the client know about the codeigniter.
ReplyDeleteThank you EugeniaLong.
ReplyDeleteI wasn’t aware of some of the information that you mentioned so I want to just say thank you.
ReplyDeleteThanks FatimaCummings
DeleteI do agree with all the ideas you have presented in your post. They are very convincing and will definitely work. Thanks for the post.
ReplyDeleteThank you RheaBradshaw
Deletethanks for your help i am new on this framework and it help me very much
ReplyDeleteI am glad that you got help from me
Delete