Search code examples
laravellaravel-5laravel-5.3laravel-5.4laravel-pagination

Laravel 5/ 5.4 paginator is not working in NGINX production environement


In my local environment i did $items = Model::paginate(10); and it worked. Then i pushed it to production and when i click on the pagination links it displays page 1 again and again. then i did dd($items). i found that the current Page property of length aware pagination is not changing when i change the address to /items?page=*. How to make current page property change accordingly or there is some thing else? thanks in advance


Solution

  • I am using ubuntu 16.04 nginx server. The problem was that $_GET session variables were not being set properly. so what I did was inside /etc/nginx/sites-available/default and inside location / block/ directive I changed try_files $uri $uri/ /index.php?$query_string; to try_files $uri $uri/ /index.php?$args; and it worked. Or see Laravel 5 - NGINX Server Config Issue with URL Query Strings