search
HomePHP FrameworkThinkPHPWhy is the url in thinkphp not case sensitive?

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.

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.

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!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.