当前位置:网站首页>The URL modes supported by ThinkPHP include four common modes, pathinfo, rewrite and compatibility modes
The URL modes supported by ThinkPHP include four common modes, pathinfo, rewrite and compatibility modes
2022-07-07 12:49:00 【Full stack programmer webmaster】
URL Pattern URL_MODEL Set up Common mode
0 PATHINFO Pattern 1 REWRITE Pattern 2 Compatibility mode 3
If the following modules are unified throughout your application URL Pattern , You can set in the application configuration file URL Pattern , If different modules need different settings URL Pattern , Can be set in the module configuration file .
Common mode
The common mode is also the traditional GET Pass parameters to specify the currently accessed module and operation , for example : http://localhost/?m=home&c=user&a=login&var=value m Parameter representation module ,c The parameter represents the controller ,a Parameters represent operations ( Of course, these parameters can be configured ), The latter indicates others GET Parameters . If the default variable settings conflict with your application variables , You need to reset the system configuration , For example, change to the following :
‘VAR_MODULE’ => ‘module’, // The default module gets variables ‘VAR_CONTROLLER’ => ‘controller’, // The default controller gets variables ‘VAR_ACTION’ => ‘action’, // The default operation is to get variables
The access address above becomes : http://localhost/?module=home&controller=user&action=login&var=value
Be careful ,VAR_MODULE Can only be set in the application configuration file , Other parameters can be set in module configuration
PATHINFO Pattern
PATHINFO Mode is the default of the system URL Pattern , Provides the best SEO Support , Environment compatibility has been done inside the system , So it can support most host environments . Corresponding to the above URL Pattern ,PATHINFO Under Mode URL The address is : http://localhost/index.php/home/user/login/var/value/ PATHINFO The first three parameters of the address represent the module / controller / operation . however ,PATHINFO In mode , You can still use ordinary URL Mode parameter mode , for example : http://localhost/index.php/home/user/login?var=value Still valid PATHINFO In mode ,URL It's customizable , for example , Through the following configuration :
// change PATHINFO Parameter separator
‘URL_PATHINFO_DEPR’=>’-‘,
We can also support the following URL visit : http://localhost/index.php/home-user-login-var-value REWRITE Pattern
REWRITE The pattern is PATHINFO Rewriting rule support is added on the basis of pattern , Can be removed URL The entry file in the address index.php, But it needs extra configuration WEB Rewriting rules for servers . If it is Apache You need to add .htaccess file , The contents are as follows :
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*) index.php/1 [QSA,PT,L]
Next , You can use the following URL Address visited : http://localhost/home/user/login/var/value
More environmental URL Rewrite the support reference deployment section URL rewrite .
Compatibility mode
Compatibility mode is used for unsupported PATHINFO The special environment ,URL The address is : http://localhost/?s=/home/user/login/var/value You can change the name definition of the compatibility mode variable , for example :
‘VAR_PATHINFO’ => ‘pathinfo’
PATHINFO The parameter separator is still valid for compatibility mode , for example :
// change PATHINFO Parameter separator
‘URL_PATHINFO_DEPR’=>’-‘,
With the above configuration ,URL The access address can become : http://localhost/?s=/home-user-login-var-value Compatibility mode coordination Web Definition of server rewrite rule , Can reach and REWRITE The pattern is the same URL effect .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113484.html Link to the original text :https://javaforall.cn
边栏推荐
- test
- Polymorphism, final, etc
- [statistical learning method] learning notes - support vector machine (I)
- How to apply @transactional transaction annotation to perfection?
- Utiliser la pile pour convertir le binaire en décimal
- 【统计学习方法】学习笔记——第四章:朴素贝叶斯法
- Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
- Several ways to clear floating
- [pytorch practice] image description -- let neural network read pictures and tell stories
- Creation and assignment of graphic objects
猜你喜欢

Multi row and multi column flex layout

The IDM server response shows that you do not have permission to download the solution tutorial

NPM instal reports agent or network problems

Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
![[pytorch practice] use pytorch to realize image style migration based on neural network](/img/20/8ed7113115709b6169be289b0c280a.png)
[pytorch practice] use pytorch to realize image style migration based on neural network

图形对象的创建与赋值

BGP third experiment report

Talk about four cluster schemes of redis cache, and their advantages and disadvantages

图像像素读写操作

opencv的四个函数
随机推荐
Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
HZOJ #236. 递归实现组合型枚举
Image pixel read / write operation
Several ways to clear floating
leetcode刷题:二叉树24(二叉树的最近公共祖先)
2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
非分区表转换成分区表以及注意事项
基于NeRF的三维内容生成
【从 0 开始学微服务】【01】什么是微服务
[statistical learning method] learning notes - support vector machine (I)
leetcode刷题:二叉树21(验证二叉搜索树)
【PyTorch实战】图像描述——让神经网络看图讲故事
Experiment with a web server that configures its own content
Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
【从 0 开始学微服务】【00】课程概述
Leetcode skimming: binary tree 21 (verifying binary search tree)
Master公式。(用于计算递归的时间复杂度。)
BGP third experiment report