Codeigniter 4 Tutorials
- Codeigniter 4
- Application Run
- Application Structure
- Configuration files
- Errors
- Controller
- View
- Model
- How to remove index.php from URL
- Route
- CodeIgniter URLs
- Helper
- Session
- Global Functions and Constants
- Logging Information in CI4
- Error Handling
- Signin / SignUp
- Login / Register
- CRUD
- Crud 1
- Form Validation
- Data Table
- Pagination
- File Upload
- Show Data Using Ajax
- Select2 AJAX Autocomplete Search
- Curl Post
- Rest API
- Weblink
Home » Codeigniter 4 »
What is Codeigniter 4 Routing?
Using custom routing rules.
Open the routing file located at app/Config/Routes.php
File name : index.php
$routes->get('/', 'Home::index');
This directive says that any incoming request without any content specified should be handled by the index() method inside the Home controller.
CodeIgniter reads its routing rules from top to bottom and routes the request to the first matching rule. Each rule is a regular expression (left-side) mapped to a controller and method name separated by slashes (right-side). When a request comes in, CodeIgniter looks for the first match, and calls the appropriate controller and method, possibly with arguments.
File name : index.php
Note :-
File name : index.php
When manually specifying routes, it is recommended to disable auto-routing by setting $routes->setAutoRoute(false); in the Routes.php file. This ensures that only routes you define can be accessed.
File name : index.php
$routes->get('news/(:segment)', 'News::view/$1');
$routes->get('news', 'News::index');
$routes->get('(:any)', 'Pages::view/$1');
File name : index.php
$routes->get('helloworld', 'App\Controllers\HelloWorld::index');
File name : index.php
File name : index.php
File name : index.php
File name : index.php