您的位置:首页 > 编程语言 > PHP开发

ThinkPHP中URL的4种模式

2016-12-16 22:16 197 查看
1、pathinfo模式:
http://localhost/demo39/index.php/Home/User/test/user/Lee/pass/123 ,
 默认分隔符为 /,可以在config.php中通过

'URL_PATHINFO_DEPR'=>'_' 

更改分割符,比如:_。

2、普通模式:
http://localhost/demo39/index.php?m=Home&c=User&a=test&user=Lee&pass
=123 ,

采用的就是传统的 GET模式,m
表示模块,c表示控制器,a
表示方法,后面的表示键值对,在config.php中可以修改键名称
'VAR_MODULE' =>'mm',
'VAR_CONTROLLER'
=> 'cc',
'VAR_ACTION' =>'aa',
备注:普通模式中入口文件可以省略,即
http://localhost/demo39/?m=Home&c=User&a=test&user=Lee&pass
=123 

3、REWRITE模式(重写模式) 

httpd.conf配置文件中加载了
mod_rewrite.so模块
AllowOverride None 将None
改为 All,重启wamp中的所有服务;
把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下

这样,ThinkPHP 自带的.htaccess文件就起作用了,可以过滤掉
index.php这个字

符串。
<IfModule mod_rewrite.c>

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

</IfModule>
//去除了index.php http://localhost/demo39/Home/User/test/user/Lee/pass/123
4、兼容模式

PS:兼容模式一般用于不支持PATHINFO
的特殊环境,基本上用不到
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Thinkphp