apache往nginx去轉(zhuǎn),代碼端用到了$_SERVER['PATH_INFO'],對于nginx默認是不開啟pathinfo的。所以我們就要手動開啟
1,url重寫
location / { //方法1 if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } location / { //方法2 try_files $uri $uri/ /index.php$uri; }
2,pathinfo設(shè)置
location ~ .*\.(php|php5)(.*)?$ //注意這塊,配置重寫的url { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi.conf; }
這塊要注意,location后正則要根據(jù)重寫的url來決定。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。