ThinkPHP 5.0 (1)模块、路由与获取请求参数

一、tp5的url路径格式

这里写图片描述

http://主机名/入口文件/模块/控制器/controller/操作(方法)/参数

如:

  • 文件结构如下:
    这里写图片描述

  • 对应的访问域名:

http://localhost/flavioy/public/index.php/sample/test/hello

二、URL路径简化

1、编写目录

application文件夹下的route.php

2、调用方法:动态注册

//使用Route类
use think\Route;

//调用rule方法
Route::rule('hello','sample/Test/hello');
//将后缀sample/Test/hello简化为hello
//完整参数
Route::rule('路由表达式','路由地址','请求类型','路由参数(数组)','标量规则');

域名由http://localhost/flavioy/public/index.php/sample/test/hello
简化为http://localhost/flavioy/public/index.php/hello

注意:简化后,原有的域名不再能够访问

猜你喜欢

转载自blog.csdn.net/flavioy/article/details/79271431