ThinkPHP's four URL access modes and constants

Source: Internet
Author: User
ThinkPHP has four URL access modes, which are described below. ThinkPHP has four URL access modes, which are described below.

I. normal access mode

Http://thinkphp.com/admin.php? M = user & a = checklogin & username = 123 & password = 456

M: module name (controller C), a: method (Operation, action), username (password): passed parameter

II. PATHINFO access mode

Http://thinkphp.com/admin.php/user/checklogin/username/123/password/456

Similar to the normal mode, the & is converted. the above write method is the get transmission mode, and $ _ GET ['username'] can receive the value, we can also use post transmission.

III. REWRITE mode

Http://thinkphp.com/admin/user/checklogin/username/123/password/456

This method is also called address rewriting or pseudo-static mode. You need to uncomment the "LoadModule rewrite_module modules/mod_rewrite.so" statement in the apache configuration file httpd. conf.

IV. hybrid mode

This mode is also called the compatibility mode. it is a combination of the common mode and PATHINFO mode to meet the needs of different operating systems.

The above four URL access modes can be modified in the configuration file of the project file, that is, the configuration file/config. php. the configuration parameter is "URL_MODEL ". The default access mode of ThinkPHP is the second PATHINFO mode. to change it to REWRITE mode, 'URL _ model' => 2;

Let's talk about the constants in ThinkPHP.

Many constants have been defined in ThinkPHP, such as __root _ (website ROOT directory) and _ APP _ (current project portal address), _ URL _ (current module address), _ ACTION _ (Current operation address), and _ SELEF _ (current URL address without domain name), _ CURRENT _ (Template directory of the CURRENT module)

You can refer to the ThinkPHP manual to familiarize yourself with more constants, or customize constants in the config. php file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.