In thinkphp, you can modify the parameters in "/ThinkPHP/Conf/convention.php" to make the URL case-insensitive. You only need to add "URL_CASE_INSENSITIVE=true" to the project configuration. URL case insensitivity does not change the naming rules.
The operating environment of this article: linux7.3 system, ThinkPHP5 version, Dell G3 computer.
thinkphp uses the URL to locate the module class and execute the operation method. There is a problem here, which is the case of the URL. Everyone knows As you know, Linux is very case-sensitive, that is, it is case-sensitive. However, the PHP virtual host in the Linux environment supports PHP code better than other operating systems (such as Windows systems), and thinkphp's URLs are case-sensitive.
In order to avoid this contradiction in demand methods, how can I organize the URLs of thinkphp to be the same as those of ordinary CMS systems without case distinction?
For example, in a Linux environment, it is normal for us to access the following URL.
http://www.php.cn/index.php/User/add
However, if we access
http://www.php.cn/index.php/user/add
like this, an error that the module does not exist will appear. Because we define UserAction instead of userAction, it will occur in a case-sensitive environment. If something goes wrong, such a problem will degrade the user experience. In fact, it is very simple for us to solve this problem. The system provides us with a solution.
is defined through configuration items. The configuration items in thinkphp are very important.
Need to modify the configuration: /ThinkPHP/Conf/convention.php parameters:
We only need to add the following to the project configuration:
‘URL_CASE_INSENSITIVE’=>true
In this way, the URL can be made case-insensitive. One thing to note here is that if you define this type of module class UserTypeAction, the first two letters of the module name are capitalized and accessed by underlining,
http://www.51php.com/index.php/user_type/add
URL case insensitivity does not change the naming convention of the system, and only by following the system naming convention can URL case insensitivity be correctly implemented.
Recommended study: "PHP Video Tutorial"
The above is the detailed content of Why is the url in thinkphp not case sensitive?. For more information, please follow other related articles on the PHP Chinese website!