最近看到人有說(shuō)某個(gè)PHP框架不支持nginx, 這應(yīng)該是一個(gè)理解的錯(cuò)誤, 既然是PHP框架, 肯定是用PHP程序?qū)懙? 而nginx就是運(yùn)行PHP的WEB服務(wù)器, 所以, 只能說(shuō)一些配置與apache來(lái)比, 有一些區(qū)別, 但絕對(duì)不會(huì)說(shuō)某個(gè)框架在APACHE下OK, 但在nginx是不不行的
這里貼下nginx下對(duì)偽靜態(tài)的支持, 從而來(lái)隱藏index.php文件, 在nginx的配置文件或者加載的vhosts.conf文件里面增加
server {
listen 80;
server_name ncdzsj.cn phpStudy.net;
root "D:/phpStudy/WWW/ncdzsj.cn";
location / {
index index.html index.htm index.php;
rewrite ^/$ /index.php last; #增加這一行
rewrite ^/(?!index\.php|robots\.txt|images|js|up|css)(.*)$ /index.php/$1 last; #增加這一行
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}