Welcome Guest, Not a member yet? Register   Sign In
Should "Index" be avoided as a controller name in CodeIgniter?
#3

Call your default controller by another name, aside from “Index” in order to avoid conflicts with built-in routers. For instance, you may call it ”Home” or any other appropriate name.

In order to keep “Index” as a name of your controller ensure to state custom routes in the “config/routes.php” in regards to request route to your Index controller. This will help in defining particular routing rules for various URLs.

Here's an example of how you can define a custom route in "config/routes.php" to handle "index/blah" and "index/index" differently:


Code:
$route['index/blah'] = 'Index/blah';
$route['index/index'] = 'Index/index';
Reply


Messages In This Thread
RE: Should "Index" be avoided as a controller name in CodeIgniter? - by alexwriter - 11-05-2023, 11:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB