1 month ago

Remove ?page=1 from paginate()

Posted 1 month ago by andyandy

I had this problem: //my main article page //is duplicate with previous page

So i published pagination template and used this preg_replace to remove ?page=1

//previous button link
<a class="page-link" href="{{preg_replace('/\?'.$paginator->getPageName().'=[1]$/','', $paginator->previousPageUrl())}}" rel="prev" aria-label="@lang('pagination.previous')">&lsaquo;</a>

//numbered page links
<li class="page-item"><a class="page-link" href="{{preg_replace('/\?'.$paginator->getPageName().'=[1]$/','',$url)}}">{{ $page }}</a></li>

It worked well, when I was using:


Problem is, it will stop working when I use:


Please sign in or create an account to participate in this conversation.