zoukankan      html  css  js  c++  java
  • Thinkphp的自定义路由(route.php)

    废话:因为thinkphp的默认路由会导致URL特别长,从而会影响搜索引擎优化。所以就衍生了自定义路由,尽量将URL缩短。

    这是默认的路由文件:

     1 <?php
     2 return [
     3     '__pattern__' => [
     4         'name' => 'w+',
     5     ],
     6     '[hello]'     => [
     7         ':id'   => ['index/hello', ['method' => 'get'], ['id' => 'd+']],
     8         ':name' => ['index/hello', ['method' => 'post']],
     9     ],
    10 
    11 ];

    hello可以很明显的跟/index/hello是对应的,也就是说hello其实就是index模块下的hello方法。但是要满足这个调用链,就必须要有id和name这个参数(加[]变成可选),然后id参数的属性要为get且满足d+这个正则,name参数的的属性要为post才调用index/hello

    如下所示:

     

  • 相关阅读:
    C++ 虚成员函数和动态联编
    C++ 多态公有继承
    C++ 继承特性
    C++ 公有派生
    C++ 基类与派生类
    C++ 类继承
    C++ 伪私有方法
    C++ new失败
    mysql用户授权
    linux时间设置
  • 原文地址:https://www.cnblogs.com/nul1/p/9745890.html
Copyright © 2011-2022 走看看