1
ooh 2013-11-28 11:59:28 +08:00
server {
listen 80; server_name 127.0.0.1; root /home/www/new/; index index.html index.htm index.php; location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; } # try_files $uri $uri/ /index.php; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } 你重写url试试 |
3
vvtommy 2013-11-28 14:17:34 +08:00
为什么在nginx下使用PATHINFO呢?如果仔细设计URL的话,花时间写一下rewrite规则才是不错的选择,ThinkPHP用PATHINFO只是在当年看来是一个比较“潮”的feature。
当然,回答你的问题,在nginx下安装这个module,可以打开PATHINFO支持 http://wiki.nginx.org/HttpFastcgiModule |
6
coolicer OP @ooh http://localhost/app/index.php/Index/index
我这样启动不了: server { listen 8080 default_server; server_name localhost; index index.html index.htm index.php; root /home/www/php; location / { try_files $uri $uri/ =404; if(!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } } location ~\.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; set $path_info ""; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; include /etc/nginx/fastcgi_params; } } |
7
qingting 2013-11-28 17:56:30 +08:00
|