1

配置 nginx php5-fpm (更改 domain.com)

server {
  listen 80 default;
  server_name domain.com;

  root /var/www/domain.com;
  access_log /var/log/nginx/domain.com.access_log;
  error_log /var/log/nginx/domain.com.error_log;
   index index.php;

   try_files $uri @rewrite;

  location @rewrite {
    rewrite ^/(.*)$ /index.php/$1;
  }   
  location ~ \.php {
   fastcgi_index index.php;
   fastcgi_pass 127.0.0.1:9000;
   include fastcgi_params;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_param PATH_INFO $fastcgi_path_info;
   fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }

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

此代码不适用于根路径...

例子:

domain.com/parse/a/b --> 有效 domain.com/parse --> 有效

domain.com --> 不工作

4

1 回答 1

0

以下内容应该可以帮助您解决问题:

更改try_files $uri @rewritetry_files $uri $uri/ @rewrite

更改rewrite ^/(.*)$ /index.php/$1;rewrite ^/(.*)$ /index.php?/$1 last;以防止无限重写循环。

如果这不能解决问题,请告诉我,我会进一步调查。

于 2013-05-30T19:24:19.923 回答