1--配置php.ini,使php支持pathinfo

2、配置nginx.conf
server { listen 888; server_name 你的域名; index index.html index.htm index.php; root /www/wwwroot/根目錄; #error_page 404 /404.html; include enable-php.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /\. { deny all; } location / { if ( -f $request_filename) { break; } if ( !-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } location ~ \.php { set $script $uri; set $path_info ""; if ($uri ~ "^(.+\.php)(/.+)") { set $script $1; set $path_info $2; } include fastcgi_params; fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root$script; fastcgi_param SCRIPT_NAME $script; try_files $uri =404; } access_log /www/wwwlogs/access.log; }
3、偽靜態
location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } }