Laravel 5-URL查询字符串的NGINX服务器配置问题 [英] Laravel 5 - NGINX Server Config Issue with URL Query Strings

查看:118
本文介绍了Laravel 5-URL查询字符串的NGINX服务器配置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Laravel没有从URL查询字符串中接收任何$ _GET变量. $ _GET和Input :: all()为空.

Laravel is not receiving any $_GET variables from the URL query string. The $_GET and Input::all() are empty.

示例:

example.app/ex/login.php?country=US

国家/地区"从未显示在我的$ _GET变量中

The "country=US" never shows up in my $_GET variable

经过大量研究并尝试了许多不同的NGINX配置,我现在只能在使用此示例时产生结果.

After much research and trying many different NGINX configurations, I can now only produce results when this example is used.

示例:

example.app/index.php/ex/login.php?country=US

$ _ GET变量现在显示国家名称值对.

The $_GET variable now shows the country name value pair.

在URL中允许查询字符串的正确配置是什么?

What is the proper configuration to allow query strings within the URL?

我当前的"example.app"启用网站的配置是...

My current sites-enabled configuration for my "example.app" is...

server {
listen 80;
server_name example.app;
root /home/vagrant/Code/public;

index index.html index.htm index.php;

charset utf-8;

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

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

access_log off;
error_log  /var/log/nginx/registration.app-error.log error;

error_page 404 /index.php;

sendfile off;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
}

location ~ /\.ht {
    deny all;
}

}

推荐答案

这是启用了站点的NGINX服务器配置,最终对我有用...

This is the sites-enabled NGINX server configuration that ended up working for me...

server {
    listen 80;
    server_name registration.app;
    root /home/vagrant/Code/registration/public;

    charset utf-8;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/registration.app-error.log error;
    error_page 404 /index.php;
    sendfile off;

    # Point index to the Laravel front controller.
    index index.php;

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

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        #deny all;
    }
}

这篇关于Laravel 5-URL查询字符串的NGINX服务器配置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆