Laravel 5 pagination with trailing forward slash at 301
I am using Laravel 5 and notice that pagination adds a trailing slash in front of ?page=#
it and with that it always redirects to the 301 page.
http://example.com/news/articles/?page=2
will make 301 redirects to http://example.com/news/articles?page=2
This is causing my ajax pagination to slow down because it has 2 responses.
How do I force laravel to accept http://example.com/news/articles/?page=2
so that it doesn't redirect 301?
I am basing it on this site that uses LengthAwarePaginator
.
source to share
I would do this in my controller instead of changing .htaccess
$posts= Article::latest()->paginate(4);
$posts->setPath('');//just add this line after your paginate function
or some users may prefer to add this line when they generate links in sight
$links = str_replace('/?', '?', $posts->render());
source to share