1

I have a problem with laravel where the query string shows empty:

If I do /en/news/some-news-slug, it gets the input as needed. However, if I do /en/news?page=2, it doesn't show that I have 'page' query string parameter. Here is my nginx configuration:

conf.d/php.conf

location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_intercept_errors on;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
}

server:

server {
        listen 80;
        # root and servername hidden

        location / {
                try_files $uri $uri/ /index.php$args;
        }
        index index.php;
        include conf.d/php.conf;

}

Controller:

public function index(Request $request)
{
    var_dump($request->query());
    $posts = $this->post->paginate(App::getLocale(), 2);
    foreach($posts as $post) {
        echo $post->id. ' ';
    }

    die;
}
1
  • 1
    If you want the querystring variable "page", you should probably look for $request->page or $request->input('page'). Does either of those get the right variable? Commented Jun 30, 2016 at 18:42

1 Answer 1

4

Try changing your NGINX config to

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

The change is in the $is_args

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.