Home >Backend Development >PHP Tutorial >laravel 分页 伪静态

laravel 分页 伪静态

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:34:062263browse

http://xinxian2.in/?page=3
这样怎么实现?http://xinxian2.in/page/3.html

//首页方法

<code>    public function index()
    {

        $data = Product::all();
        $data = Product::paginate(15);
        return view('home')->withPages($data);
    }
</code>

//视图模板

<code><div class="pagePaging w mt">
        <?php echo $pages->render(); ?>
</div>
</code>

回复内容:

http://xinxian2.in/?page=3
这样怎么实现?http://xinxian2.in/page/3.html

//首页方法

<code>    public function index()
    {

        $data = Product::all();
        $data = Product::paginate(15);
        return view('home')->withPages($data);
    }
</code>

//视图模板

<code><div class="pagePaging w mt">
        <?php echo $pages->render(); ?>
</div>
</code>

1;
nginx 把http://xinxian2.in/page/3.html重写成http://xinxian2.in/?page=3

<code>rewrite ^/(.*)/(.*)\.html$  /index.php?$1=$2  last;
</code>

refer:http://nginx.org/en/docs/http/ngx_http_rewrite_module.html

2;
通过框架实现,比如Symfony2可以routing.yml里重写

<code>xx_yy_zz:
    pattern:  /{type}/{id}.html
    defaults: { _controller: XxBundle:Yy:zz }
</code>

再访问http://xinxian2.in/page/3.html时

<code>class YyController extends BaseController
{
    zzAction(Request $request, $type, $id)
    {
      //$type = page, $id = 3
    }
}
</code>

laravel应该也有相应的做法

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn