ThinkPHP中URL的4种模式
2016-12-16 22:16
281 查看
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
的特殊环境,基本上用不到
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
的特殊环境,基本上用不到
相关文章推荐
- kindeditor 批量上传 上传失败 thinkphp swfupload session
- ThinkPHP关联模型操作实例分析
- thinkphp3.0 模板中函数的使用
- thinkPHP的表达式查询用法详解
- ThinkPHP中where()使用方法详解
- ThinkPHP采用<volist>实现三级循环代码实例
- jquery+thinkphp实现跨域抓取数据的方法
- Thinkphp模板标签if和eq的区别和比较实例分析
- 合并ThinkPHP配置文件以消除代码冗余的实现方法
- ThinkPHP中自定义目录结构的设置方法
- ThinkPHP控制器详解
- ThinkPHP自动转义存储富文本编辑器内容导致读取出错的解决方法
- 解析thinkphp中的M()与D()方法的区别
- ThinkPHP采用模块和操作分析
- Thinkphp模板中使用自定义函数的方法
- linux下使用ThinkPHP需要注意大小写导致的问题
- ThinkPHP中FCKeditor编辑器的使用方法
- thinkphp的CURD和查询方式介绍
- THINKPHP支持YAML配置文件的设置方法
- Thinkphp中import的几个用法详细介绍