>백엔드 개발 >PHP 튜토리얼 >laravel 分页 伪静态

laravel 分页 伪静态

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB원래의
2016-06-06 20:34:062257검색

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应该也有相应的做法

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.