I just want to know the purpose of this on routes.php
$route['default_controller'] = "welcome";
$route['scaffolding_trigger'] = "";
Let me first take your through routing and then tell you about the meaning of those lines in routes.php
.
You should start with URI Routing . In short, what you do with routes is that you map a certain URI
with a controller/method/parameter
statement.
See the following examples taken from the user guide:
So, something like example.com/journals
can be routed to the blogs
controller.
$route['journals'] = "blogs";
Another good example is when you are building a product catalogue and you need example.com/product/some_id
to be routed to a controller catalog
:
$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";
In the example above, catalog
will be the controller, product_lookup_by_id
will be the method and $1
is the parameter which is picked up from the URI.
You have asked:
I just want to know the purpose of this on routes.php
$route['default_controller'] = "welcome"; $route['scaffolding_trigger'] = "";
The default_controller
is quite obvious. This means welcome/index
will be loading whenever `example.com/index
is being requested.
scaffolding_trigger
was deprecated in 1.7 but you can read about it . Scaffolding was a method which you could use to seed data in your database.
$route['default_controller'] = "welcome";
This is the default controller which codeigniter would start with when you didnt specify a controller to the URL.
url:
ip/monitor/index.php
This will trigger the default controller aka welcome.php
url:
ip/monitor/index.php/controller
This will, however, trigger your given controller and not the default one
This is mostly used to asign a index page as the start page.
I'm not sure about $route['scaffolding_trigger'] = "";
as i never used it. But according to the comments it has been removed in version 2.0
Routing rules are defined in your application/config/routes.php file. In it you'll see an array called $route that permits you to specify your own routing criteria. Routes can either be specified using wildcards or Regular Expressions.
For more detail please see this link :
http://ellislab.com/codeigniter%20/user-guide/general/routing.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.