Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

handy_man's avatar

pagination works locally but not in production?

I have a simple logging system that logs information about when a user did things (added a reservation, edit, delete etc).

Logs as you can imagine get a bit large, so I decided to paginate my data and this works fine on my local development environment (Windows with XAMPP) but not in my production environment (Ubuntu 14.04 with Nginx web server).

My Controller:

    public function logs()
    {
        $logs = Logs::orderBy('created_at', 'DESC')->paginate(25);

        $logs->setPath('');

        return view('admin.logs', compact('logs'));
    }

my view:

   <div class="container">

        <table class="table table-striped">
            <thead>
            <tr>
                <th>Log ID</th>
                <th>User</th>
                <th>Action</th>
                <th>Description</th>
                <th>When</th>
            </tr>
            </thead>
            <tbody>
            @foreach($logs as $log)

                <tr>
                    <td>{{$log->id}}</td>
                    <td>{{$log->user->name }}</td>
                    <td>{{$log->action }}</td>
                    <td>{{$log->description}}</td>
                    <td>{{$log->created_at}}</td>
                </tr>
            @endforeach
            </tbody>
        </table>

        {!! $logs->render() !!}

    </div>

Everything renders correctly, pagination even shows the number of pages I'd need for my production environment logs but when clicking the numbers or next the page changes and the url changes but the data is exactly the same in production but changes in my development environment.

0 likes
2 replies
jpvf's avatar
jpvf
Best Answer
Level 3

That may be an issue with the nginx configuration, check the site configuration looks like the following, it has helped me in the past:

location / {
   try_files $uri $uri/ /index.php$is_args$args;
}
handy_man's avatar

The above worked for me so to clarify for anyone else I had:

        try_files $uri $uri/ /index.php?$query_string;

and changed it to the above:

location / {
   try_files $uri $uri/ /index.php$is_args$args;
}

and then restarted the nginx server and all appears to work fine.

1 like

Please or to participate in this conversation.