thinkphp URL rules, url pseudo-static, URL routing 
 
Thinkphp 3.1.2? URL rules, url pseudo-static, URL routing
 
First, URL rules
 
1, the URL by default is case-sensitive
 
2, if we do not want to distinguish between the case can change the configuration file
 
' Url_case_insensitive ' =>true,//value of true is a description URL is case-insensitive
 
3. If the module is named Usergroupaction
 
Then the URL to find the module is necessary to write
 
Http://localhost/thinkphp/index.php/user_group/index
 
4, if ' url_case_insensitive ' =>false? Case sensitive
 
Then the URL can also be written as
 
Http://localhost/thinkphp/index.php/UserGroup/index
 
Second, the URL pseudo-static
 
' Url_html_suffix ' = ' html|shtml|xml ',//limit pseudo-static suffix
 
Third, URL routing
 
1. Start the route
 
To turn on routing support in the configuration file
 
? ? ? ? ? ? ? ? ' Url_router_on ' =>true,
 
? ? ? ? ? ? ? ? and configure the ' url_route_rules ' parameter
 
?
 
2. Using routing
 
1. Rule Expressions Configure Routing
 
' My ' = ' index/index ',//static address routing
 
': id/:num ' = ' index/index ',//dynamic address Routing
 
' year/:year/:month/:d ate ' = ' index/index ',//dynamic and static mixed address routing
 
' year/:year\d/:month\d/:d ate\d ' = ' index/index ',//dynamic and static mixed address routing?
 
Plus the \D representative type can only be numeric
 
' my/:id$ ' = ' index/index ',//plus $ description address can only be my/1000 behind cannot have other content
 
2. Regular expression Configuration routing
 
'/^year\/(\d{4}) \ (\d{2})/(\d{2})/' = ' index/index?year=:1&month=:2&date=:3 '
 
3. Precautions:
 
1. More complex routes to the front, or cause URL parsing confusion
 
' Url_route_rules ' =>array (
 
' my/:year/:month:/:d ay ' = ' index/day ',
 
' my/:id\d ' = ' index/index ',
 
' My/:name ' = ' index/index ',
 
)
 
2. You can use the route rule as an exact match, indicating that it ends and cannot be followed by other parameters
 
' Url_route_rules ' =>array (
 
' my/:id\d$ ' = ' index/index ',
 
' my/:name$ ' = ' index/index ',
 
' my/:year/:month:/:d ay$ ' = ' index/day ',
 
),
 
3. Using regular matching methods
 
' Url_route_rules ' =>array (
 
'/^my\/(\d+) $/' = ' index/index?id=:1 ',
 
'/^my\/(\w+) $/' = ' index/index?name=:1 ',
 
'/^my\/(\d{4}) \ (\d{2})/(\d{2}) $/' = ' index/day?year=:1&month=:2&day=:3 ',
 
),
 
?
 
?