저는 nginx 1.6.1 및 php-fpm 5.5.9를 실행하고 있습니다. SEF URL을 만들 수있는 설정이 있습니다. index.php를에,SEF URL이있는 Nginx는 GET 변수를 전달하지 않습니다.
location/{
# first try if the file or directory exists; if not, redirect to index.php
# then index.php will see what to do based on the REQUEST_URI
try_files $uri $uri/ /index.php;
}
# and just the basic php-fpm setup...
location ~* \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi.conf is as distributed, and doesn't contain anything special
# anyway, the file is shown below
include fastcgi.conf;
}
다음 : 다음의 nginx 구성의 관련 부분을 참조하십시오
// Just for testing
var_dump($_SERVER);
var_dump($_GET);
을 지금, 나는이 밖으로 시도 몇 가지 다른 일이 있습니다 :
My request REQUEST_URI GET is passed?
-----------------------------------------------
/index.php?test /index.php?test Yes
/index.php/?test /index.php/?test No
/?test /?test Yes
?test (redirected to /?test)
/some-dir?test /some-dir?test No
/some-dir/?test /some-dir/?test No
/index.php/?test
을 그 작동하지 않습니다 큰 문제가되지 않습니다. 어쨌든, 결국 nginx를 사용하여 후행 슬래시를 제거 할 수 있습니다. 그런데 왜 마지막 두 경우의 GET 변수가 전달되지 않습니까?
물론 PHP에서 REQUEST_URI를 사용하여 parse_url
을 사용하여 작업을 수행 할 수는 있지만 $ _GET을 사용하여 변수에 액세스 할 수 있다면 훨씬 더 좋습니다. 무슨 일있어?
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;