当前位置:网站首页>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
边栏推荐
- 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)
- [binary tree] delete points to form a forest
- ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
- Day-14 common APIs
- 图形对象的创建与赋值
- 【二叉树】删点成林
- ICLR 2022 | pre training language model based on anti self attention mechanism
- Importance of database security
- Charles: four ways to modify the input parameters or return results of the interface
- Zhimei creative website exercise
猜你喜欢
聊聊Redis缓存4种集群方案、及优缺点对比
How to apply @transactional transaction annotation to perfection?
Polymorphism, final, etc
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
Zhimei creative website exercise
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
leetcode刷题:二叉树20(二叉搜索树中的搜索)
Session
ICLR 2022 | pre training language model based on anti self attention mechanism
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
随机推荐
3D content generation based on nerf
2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
File upload vulnerability - upload labs (1~2)
IPv6 experiment
ip2long与long2IP 分析
[learn microservice from 0] [01] what is microservice
[statistical learning methods] learning notes - Chapter 4: naive Bayesian method
[learn microservices from 0] [03] explore the microservice architecture
Vxlan static centralized gateway
HZOJ #240. 图形打印四
Configure an encrypted web server
Guangzhou held work safety conference
图形对象的创建与赋值
Leetcode brush questions: binary tree 19 (merge binary tree)
[difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
idm服务器响应显示您没有权限下载解决教程
SQL Lab (46~53) (continuous update later) order by injection
Zhimei creative website exercise
What if does not match your user account appears when submitting the code?