Home> PHP Framework> ThinkPHP> body text

Why is the url in thinkphp not case sensitive?

WBOY
Release: 2022-04-06 11:57:52
Original
2316 people have browsed it

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.

Why is the url in thinkphp not case sensitive?

The operating environment of this article: linux7.3 system, ThinkPHP5 version, Dell G3 computer.

Why is the URL in thinkphp not case-sensitive

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.

//m.sbmmt.com/index.php/User/add
Copy after login

However, if we access

//m.sbmmt.com/index.php/user/add
Copy after login

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
Copy after login

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
Copy after login

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.

Why is the url in thinkphp not case sensitive?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!