我的laravel有问题,查询字符串显示为空:
如果我执行/ en / news / some-news-slug,它会根据需要获取输入。但是,如果我执行/ en / news?page = 2,则表明我没有'page'查询字符串参数。这是我的nginx配置:
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 {
listen 80;
# root and servername hidden
location / {
try_files $uri $uri/ /index.php$args;
}
index index.php;
include conf.d/php.conf;
}
控制器:
public function index(Request $request)
{
var_dump($request->query());
$posts = $this->post->paginate(App::getLocale(), 2);
foreach($posts as $post) {
echo $post->id. ' ';
}
die;
}
答案 0 :(得分:3)
尝试将NGINX配置更改为
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
更改位于 $ is_args
中