01. Hello.php we add a controller in the controller, as follows;
<?php namespace App\Controllers; // http://127.0.0.1/CI4/public/index.php/hello/ class Hello extends BaseController { public function show1() { echo 'green Zijin Youyouwoxin' ; } public function show2() { echo 'your hand and grow old' ; } public function index() { echo 'life difficult for water Gorges cloud' ; } }
02. We visited in the browser: http: //127.0.0.1/CI4/public/index.php/hello/
03. We added URI in the route packet App / Config / Routes.php code is as follows:
//以分组的形式添加 $routes->group('abc', function ($routes) { $routes->add('/', 'Hello::index'); $routes->add('show', 'Hello::show1'); }); //以单条的形式添加 $routes->get('abc/aaa', 'Hello::show2');
04.大功告成,我们现在可以用浏览器访问重定向路由之后的地址:
http://127.0.0.1/CI4/public/index.php/abc/
http://127.0.0.1/CI4/public/index.php/abc/show
http://127.0.0.1/CI4/public/index.php/abc/aaa
原创不易,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢。