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

laravel 分页 伪静态

WBOY
Release: 2016-06-06 20:34:06
Original
2234 people have browsed it

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>
Copy after login
Copy after login

//视图模板

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

回复内容:

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>
Copy after login
Copy after login

//视图模板

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

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

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

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>
Copy after login

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

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

laravel应该也有相应的做法

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template