What Will I Learn?
- You will learn Basic Routing
- You will learn Create Routing
- You will learn Use Routing
Requirements
- Xampp
- Sublime
- Codeigniter
Difficulty
- Basic
Tutorial How to run and create routing in codeigniter
A. Basic Route
- routing directory is on application/config/routes.php .
- the section of code $route['default_controller'] = 'welcome'; that shows on the default controller or controller that is first read by CI, default is there on the controller welcome . welcome is page.
- the section of code $route['404_override'] = '';are used to notify the CI if default controller can not be found or if there is a controller of others or other pages that are not found
- the section of code $route['translate_uri_dashes'] = FALSE; is working if you change the value TRUE, then you are allowed in a URL the browser you are writing a mark dash (-).
B. Create Route
Here are a few create routing :
$route['code'] = 'example';
A URL containing the word “code” in the first segment will be remapped to the “example” class.
$route['example/iwaydi'] = 'example/users/22';
A URL containing the segments example/iwaydi will be remapped to the “example” class and the “users” method. The ID will be set to “22”.
$route['product/(:any)'] = 'blogs/content';
A URL with “product” as the first segment, and anything in the second will be remapped to the “blogs” class and the “content” method.
$route['product/(:num)'] = 'blogs/content_id/$1';
A URL with “product” as the first segment, and a number in the second will be remapped to the “blogs” class and the “content_id” method passing in the match as a variable to the method.
Important
Do not use leading/trailing slashes.
C. Use Routing
Open application/config/routes.php with sublime
You can edit welcome with your controller who want first show in website. I want first show is mypage
You can looking result my page here
If you want to display your own controller page of error. you can type your controller in the second code
You can looking result notfound here
Curriculum
** This is the first tutorial i'm contributing using Codeigniter.**
Posted on Utopian.io - Rewarding Open Source Contributors
Nice post man!
Just posted a similar php routing solution using Flight PHP, check out on my profile!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I wonder what you are saying now. You will not talk about intigers in a routing tutorial. I liked what has been explained here.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit