標籤:include root style nginx 環境配置 stc ati ... dex
找到/usr/local/webserver/nginx/conf/nginx.conf檔案(環境配置不一樣,路徑也可能不一樣)
並在server {...省略掉的代碼}中添加如下代碼即可(如果程式放在根目錄下用一級目錄代碼,放在二級目錄,請用二級目錄代碼),改好後重啟nginx:
###############開啟pathinfo支援(如果已開啟請忽略此處)##############
location ~ \.php { fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
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$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;}
###############配置偽靜態(一級目錄下隱藏index.php)##############
if (!-e $request_filename) {
###程式放在一級目錄下(如:http://www.phpshe.com/)
rewrite ^/(.*)$ /index.php/$1 last;
}
###############配置偽靜態(二級目錄下隱藏index.php)##############
if (!-e $request_filename) {
###程式放在二級目錄下(如:http://www.phpshe.com/shop/)
rewrite ^/二級目錄名/(.*)$ /二級目錄名/index.php/$1 last;
}
phpshe b2c商城系統配置nginx支援pathinfo和rewrite的寫法