This article mainly introduces how to enable ThinkPHP to support access by case-sensitive URLs. it is a very useful technique for developing ThinkPHP programs in Windows. if you need ThinkPHP, refer to ThinkPHP.
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/index. php/Article 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
The link obtained by using/index. php/Article in the template is still the one below, and there is no underline.
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/index. php/Article is defined here:
The code is as follows:
$ ModuleName = defined ('Module _ alias ')? MODULE_ALIAS: MODULE_NAME;
If (defined ('group _ name ')){
Define ('/index. php/article ',! Empty ($ domainModule )? /Index. php. $ depr:/index. php. $ depr. (C ('URL _ CASE_INSENSITIVE ')? Strtolower ($ moduleName): $ moduleName ));
} Else {
Define ('/index. php/article ',! Empty ($ domainModule )? /Index. php. '/':/index. php. '/'. (C ('URL _ CASE_INSENSITIVE ')? Strtolower ($ moduleName): $ moduleName ));
}
Put
The code is as follows:
C ('URL _ CASE_INSENSITIVE ')? Strtolower ($ moduleName): $ moduleName)
Changed:
The 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.