The example in this article describes a method that lets thinkphp support case-and-write URL address access. Share to everyone for your reference. The implementation methods are as follows:
Usually thinkphp by default is a case-sensitive URL, this is the same as the Linux system in the lowercase URL is two different names, but we use Windows accustomed to the same as the case, so we still have to deal with the problem according to user habits, the following we look at the problem solving method.
The thinkphp case recognition feature is turned on in the configuration file so that the case of the link can be accessed properly:
' Url_case_insensitive ' =>true
File naming is canonical, but when you use __url__ in the template to get the current URL path, you do not get the URL correctly.
This is written in the manual:
Here is a place to note that if we define a Usertypeaction module class, then the URL should be accessed by:
Http://serverName/index.php/user_type/list
Instead of
Http://serverName/index.php/usertype/list
The link to use __url__ in the template or the one below is not underlined.
This problem on the Internet also has a lot of people feedback, there is a solution is to modify the TP source code:
In the Dispatcher.class.php file in the core folder of the TP Lib folder, find 181 rows, where the __url__ address is defined:
Copy Code code as follows:
$moduleName = defined (' Module_alias ')? Module_alias:module_name;
if (defined (' Group_name ')) {
Define (' __url__ ',!empty ($domainModule)? __group__. $depr: __group__. $depr. ( C (' url_case_insensitive ')? Strtolower ($moduleName): $moduleName));
}else{
Define (' __url__ ',!empty ($domainModule)? __app__. ' /': __app__. ' /'. (C (' url_case_insensitive ') strtolower ($moduleName): $moduleName));
}
Put the
Copy Code code as follows:
C (' url_case_insensitive ')? Strtolower ($moduleName): $moduleName)
Change into:
Copy Code code as follows:
C (' url_case_insensitive ') parse_name ($moduleName, 0): $moduleName
So the problem is done!
I hope this article will be helpful to everyone's thinkphp framework program design.