Enable ThinkPHP to support access using case-sensitive URLs. thinkphp is case-sensitive.
This example describes how to enable thinkphp to support access with case-insensitive URLs. Share it with you for your reference. The specific implementation method is as follows:
Generally, ThinkPHP uses URLs of different upper and lower cases by default. This is the same as that of linux systems. Two different names are available in lower case URLs. However, we use windows to consider ThinkPHP as case-sensitive, therefore, we still need to solve the problem according to user habits. Let's take a look at the solution.
The thinkphp case sensitivity function is enabled in the configuration file so that all links can be accessed normally:
'Url _ CASE_INSENSITIVE '=> true
The file names are standard, but the URL is not obtained correctly when _ url _ is used in the template to obtain the current url path.
Write the following in the manual:
Note that if we define a module class of UserTypeAction, the URL access should be:
Http: // serverName/index. php/user_type/list
Instead
Http: // serverName/index. php/usertype/list
In the template, use _ URL _ to obtain the link or the following link, which is not underlined.
Many people have reported this problem on the Internet. The solution is to modify the source code of tp:
In the Dispatcher. class. php file in the Core folder of the Lib folder of tp, locate row 181. The address acquisition method of _ URL _ is defined here:
Copy codeThe Code is 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 ));
}
PutCopy codeThe Code is as follows: C ('url _ CASE_INSENSITIVE ')? Strtolower ($ moduleName): $ moduleName) changed:
Copy codeThe Code is as follows: C ('url _ CASE_INSENSITIVE ')? Parse_name ($ moduleName, 0): $ moduleName
The problem is solved!
I hope this article will help you with ThinkPHP framework programming.
Thinkphp path case sensitivity and url Problems
Is the Public folder in the root directory? If yes, use/Public/or _ PUBLIC _/(Double underline ).
How does ThinkPHP make the group names in the URL automatically lowercase? -PHP framework development
I am also troubled by this problem throughout the afternoon, and finally I am in ThinkPHP/Common/functions. the U function in php adds a [ol] [*] $ url = C (\ 'url _ CASE_INSENSITIVE \')? Strtolower ($ url): $ url; [/ol]