主要作用:隐藏自己的真实路由名称

application/Route.php

 

使用方法一:

<?php
use think\Route;
Route::alias('home','index/index');
Route::alias('admin','admin/index');

 

方法二:

<?php


return [
    '__pattern__' => [
        'name' => '\w+',
    ],
    '[hello]'     => [
        ':id'   => ['index/hello', ['method' => 'get'], ['id' => '\d+']],
        ':name' => ['index/hello', ['method' => 'post']],
    ],

    '__alias__' =>  [
        'home'  =>  'index/index',
       'admin'=> 'admin/index'
    ],

];

 

http://localhost/thinkphp/index.php/home/test 同等与http://localhost/thinkphp/index.php/index/index/test

http://localhost/thinkphp/index.php/admin/edit/ 同等与http://localhost/thinkphp/index.php/admin/index/edit

 

注释:别名 => ‘模型/控制器’ ( 别名等于模块+控制器)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
  • 2021-09-14
  • 2021-06-05
  • 2021-07-07
  • 2021-06-18
猜你喜欢
  • 2021-08-27
  • 2021-10-21
  • 2021-11-05
  • 2022-12-23
  • 2021-05-06
  • 2021-08-07
  • 2022-12-23
相关资源
相似解决方案