ThinkPHP 5.0 (1) Modules, routing and obtaining request parameters

1. url path format of tp5

Write picture description here

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

like:

  • The file structure is as follows:
    Write picture description here

  • Corresponding access domain name:

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

2. Simplification of URL paths

1. Write a directory

application文件夹下的route.php

2. Calling method: dynamic registration

//使用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

Note: After simplification, the original domain name can no longer be accessed

Guess you like

Origin blog.csdn.net/flavioy/article/details/79271431