为啥我的TP5在生成URL的时候总带/public

浏览:5238 发布日期:2016/12/15 分类:ThinkPHP5专区 关键字: thinkphp5 路由 生成URL
<?php
namespace app\index\controller;
use \think\Request;
class Index
{
    public function index()
    {
        return '<style type="text/css">*{ padding: 0; margin: 0; } .think_default_text{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>';

    }
    public function tt($var = 'default')
    {
        
        echo "VAR: $var<br>";
        $request = Request::instance();
        dump(request()->param());
        echo url('tt',['var' => 'customer']);
    }

}
路由文件:<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

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

];
结果:VAR: customer
array(1) {
  ["var"] => string(8) "customer"
}
/public/index/index/tt/var/customer.html
生成页面最后一行的URL中 开头部分多出的/public肯定是我不想要的
并且直接访问话当然会导致找不到控制器,虽然我可以在写一个算法去掉Pubilc,但是要找到原因会比较好。
然后发现就算去掉/public 会显示:
非法请求:index/index/tt/var/customer。。又是为什么呢
为啥我的TP5会是这样子的啊,完全按照官方手册写的
难道是bug吗。。请各位大侠帮忙!!~~
最佳答案
评论( 相关
后面还有条评论,点击查看>>