What is the basic CodeIgniter URL structure?

Instead of using ‘query-string’ approach, it uses a segment based approach.

Its structure is as follows,

abc.com/class/function/ID
The class represents a controller class that needs to be invoked.

The function is the method that is called.

ID is an additional segment that is passed to controllers.

In CodeIgniter, the basic URL structure follows a pattern where the base URL of the application is followed by a controller class name, followed by a method within that controller, and any parameters needed for that method.

The basic CodeIgniter URL structure is as follows:

bash
http://example.com/index.php/controller/method/parameter1/parameter2/...

Where:

  • http://example.com/ is the base URL of the application.
  • index.php is the default PHP file for handling requests.
  • controller is the name of the controller class that will be invoked.
  • method is the name of the method within the controller class that will be executed.
  • parameter1, parameter2, etc., are optional parameters passed to the method.

It’s worth noting that in CodeIgniter, you can configure the URL structure to remove index.php and have cleaner URLs by modifying the .htaccess file and configuration settings. This makes the URL look like:

bash
http://example.com/controller/method/parameter1/parameter2/...

This structure is essential for understanding how CodeIgniter routes requests and executes controller methods.