Requirements: When accessing this directory, http://xx.com/p-412313 is redirected to (for the time being) http://xx.com/Home/Blog/index/id/412313
Just looking good.
My application directory is application. Module is home
Step one: Know which file to do with the route
Routing processing in think/route.class.php
Dynamic routing processing
$routes = C (' url_route_rules ');
Var_dump ($routes);
if (!empty ($routes)) {
//dump ($routes);
Array (1) {
//["/^p-(\d+) $/"] => string "blog/index?id=:1"/
/}
//echo "rount.class.php\n";
foreach ($routes as $rule => $route) {
if (is_numeric ($rule)) {
//support Array (' rule ', ' adddress ',...) to define routing
$rule = array_shift ($route);
}
... More code, identify location only
Step two: Under the configuration file of the project module, set the configuration file as follows (because TP is a step-by-step configuration file, the custom configuration-> application configuration-> mode matching
-> Debug Configuration-> state configuration-> Module configuration-> Extended configuration-> dynamic configuration, which belongs to the module configuration
<?php return
Array ('
module_allow_list ' => Array (' Home ', ' Admin ', ' Common '),
' Default_module ' => ' home ', ///default module
' Default_controller ' => ' Index ',//Default controller name
' Default_ Action ' => ' index ',///default action name
// Routing Rule
' url_router_on ' => TRUE,
' Url_route_ RULES ' => Array (
'/^c-(\d+) $/' => ' index/content?id=:1 '
),
' url_router_on ' =>true,
' Url_model ' => ' 1 ',
' url_route_rules ' =>array ('/^p-' \d+ ' $/' => ' home/blog/index?id=:1 '
,/ It means to visit the x.com/p-34 will visit the x.com/blog/index/id/34
)
;
Part III:
If you do not set the default module, there will be a failure to find p-34 this module.
Then you need to set up in index.php
Define (' Bind_module ', ' home ');
That's it.
Description: If there is no third step. It is normal to open by default.
But
So we do the third step, we can achieve the following effect: