Laravel 5 / 5.4 paginator not working in NGINX production Enviroment

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 page links it renders page 1 over and over again. Then I did dd($items)

. I found that the property current Page

length aware pagination

doesn't change when I change the address to /items?page=*

. How do I change the current page change, or something else? thank you in advance

+3


source to share


2 answers


I am using ubuntu 16.04 nginx server. The problem was that the session variables $_GET

were not set properly. so what i did 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 have a look at Laravel 5 - NGINX Server Configuration Issue with URL Strings



+2


source


Awsome Thanks #Ahmed

I just needed to change mine from

location / {    
    try_files $uri $uri/ /index.php?$query_string;
}

      



to

location / {
    index index.php;
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    rewrite ^(.*)$ /index.php/$1 last;
}

      

as I've seen some of my other sites, used the @rewriteapp part and seemed to work fine.

0


source







All Articles