2016-10-30 5 views
0

メソッドパラメータを取得できるようになりました。 調査によると、私はPHPに気づくと、PHPでパラメータを取得することができません。 この決議を知っていますか? NginxやPHPの設定が原因だと思います。nginxとphpでメソッドパラメータを取得する方法

Nginxの設定は次のとおりです。

server { 
listen  80; 
server_name localhost; 
#charset koi8-r; 
#access_log /var/log/nginx/log/host.access.log main; 

location/{ 
    root /var/www/html/startup_intern/public; 
    index index.php index.html index.htm; 
    try_files $uri $uri/ /index.php$query_string; 
    add_header 'Access-Control-Allow-Origin' "localhost:3001"; 
    add_header 'Access-Control-Allow-Credentials' 'true'; 
    add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; 
    add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With'; 
} 

#error_page 404    /404.html; 

# redirect server error pages to the static page /50x.html 
# 
error_page 500 502 503 504 /50x.html; 
location = /50x.html { 
    root /var/www/html/startup_intern/public; 
} 

# proxy the PHP scripts to Apache listening on 127.0.0.1:80 
# 
#location ~ \.php$ { 
# proxy_pass http://127.0.0.1; 
#} 

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
# 
location ~ \.php$ { 
    # root   html; 
    fastcgi_pass 127.0.0.1:9000; 
    #fastcgi_pass /var/run/php-fpm/php-fpm.sock; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME /var/www/html/startup_intern/public/$fastcgi_script_name; 
    include  fastcgi_params; 
} 

# deny access to .htaccess files, if Apache's document root 
# concurs with nginx's one 
# 
#location ~ /\.ht { 
# deny all; 
#} 
} 
+1

"私はPHPにパラメータを取得することはできません"と私はとても混乱しています。 「getメソッドのパラメータ」の例と、それを実行しようとしているPHPコードを表示できますか? –

+0

ああ、申し訳ありません。はい、私はそれを書きます。 あまりにも単純です。私はLaravelに使用していますので、私はLaravelのindex.phpをコードの下に書きます。 しかし、私はいくつかのパラメータを得ることができません。 URL:http://192.168.33.10/company/?email = testdata&company = test2 var_dump($ _ GET); var_dump($ _ REQUEST); –

+0

あなたはいくつかのパラメータを得ることができないと言ったが、あなたの目的の結果は何ですか? –

答えて

0

nginxの設定に問題があるようです。行:

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

バグがあります。 Nginxのドキュメントによると、try_filesディレクティブは指定されたURLを順番に試してみるというものです。最初のものが成功した場合はそれが戻り、それ以外の場合は次のURLがチェックされます。 (http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files)。あなたの場合、最初のURLはクエリパラメータなしで$ uriです。あなたのURLの順序を切り替えると、あなたのPHPスクリプトは、クエリ文字列にアクセスできる必要があります。あなたは以下を試すことができます:

try_files /index.php$query_string $uri $uri/; 
関連する問題