The ThinkPHP framework is accessed through modules and operations. because ThinkPHP Framework applications use a single entry file for execution, therefore, all the modules and operations of the website are accessed and executed through URL parameters. as a result, the traditional file portal access will become
The ThinkPHP framework is accessed through modules and operations. because ThinkPHP Framework applications use a single entry file for execution, therefore, all the modules and operations of the website are accessed and executed through URL parameters. as a result, the traditional file portal access will be resolved and scheduled by URL parameters in a unified manner.
ThinkPHP's powerful URL parsing, scheduling, and routing functions provide a powerful guarantee for the implementation of this function, and can be successfully deployed in most server environments.
ThinkPHP supports four URL modes, which can be defined by setting the URL_MODEL parameter, including the normal mode, PATHINFO, REWRITE, and compatibility mode.
1. normal mode: set URL_MODEL to 0.
Use the traditional URL parameter mode
Http: // serverName/appName /? M = module & a = action & id = 1
II. PATHINFO mode (default mode): Set URL_MODEL to 1.
PATHINFO mode is used by default. ThinkPHP has built-in powerful PATHINFO support, which provides flexible and friendly URL support. PATHINFO mode automatically identifies modules and operations, such
Http: // serverName/appName/module/action/id/1/
Or
Http: // serverName/appName/module, action, id, 1/
Without considering routing, the first parameter will be parsed into a module name (if grouping is enabled, it will be rolled back in sequence), and the second parameter will be parsed into an operation, the following parameters are explicitly transmitted and must appear in pairs. for example:
Http: // serverName/appName/module/action/year/2008/month/09/day/21/
The delimiter between parameters is set by the URL_PATHINFO_DEPR parameter. the default delimiter is "/". for example, if URL_PATHINFO_DEPR is set to "-", the following URL can be used for access.
Http: // serverName/appName/module-action-id-1/
Do not use the ":" and "&" symbols to separate them. these symbols are used for special purposes.
By adding a few modifications, you can see a poetic URL ~ If you want to simplify the URL format, you can use the routing function (which will be described later) as well as the empty module and empty operation. in PATH_INFO mode, the related parameters are converted to GET variables, and is incorporated into the REQUEST variable, so it does not prevent the GET and REQUEST variables in the URL from being obtained.
3. REWRITE mode: set URL_MODEL to 2.
The URL mode has the same functions as the PATHINFO mode, except that you do not need to write an entry file in the URL or define a. htaccess file. After the URL_REWRITE module of Apache is enabled, you can enable the REWRITE mode. for details, refer to the URL rewriting section below.
4. compatibility mode: set URL_MODEL to 3.
The compatibility mode is the combination of the common mode and the PATHINFO mode, and enables the application to directly switch to the PATHINFO mode as needed without changing the template and program. It can also be integrated with the URL_WRITE mode. The compatible mode URL supports any running environment.
The compatibility mode works as follows: http: // serverName/appName /? S =/module/action/id/1/
The parameter delimiter can also be defined. for example, when URL_PATHINFO_DEPR is ~ The following URL is valid:
Http: // serverName/appName /? S = module ~ Action ~ Id ~ 1
In fact, the VAR_PATHINFO parameter is used to simulate the PATHINFO mode in normal mode. However, the compatibility mode does not need to pass the s variable itself, but the URL part is automatically completed by the system, because of this feature, the compatibility mode can be directly switched to the PATHINFO mode without changing the URL connection in the template file.
Some server environments do not support PATHINFO well, but ThinkPHP can be compatible in most environments. if your server environment or space still cannot recognize PAHTINFO, alternatively, you need to add identification methods or select normal or compatible mode to run URLs. We recommend that you use the PATHINFO mode for development. if the environment does not support PATHINFO during deployment, you can change it to the compatible URL mode for deployment. you do not need to change the program and template.
Note:If the current mode is set to another mode, but the URL contains a compatible mode matching parameter, it will be automatically identified, that is, the compatibility mode is prioritized.