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