需求:
(1)你希望通过www.domain.com/module/controller/action而不是www.domain.com/index.php/module/controller/action来访问你的项目。(2)如果你是用的也是nginx服务器。就可以通过修改vhosts.conf配置文件实现。
完整配置文件如下:
server {
server_name www.example.com;
root /home/wwwroot/project;
index index.php index.html index.htm
location / {
autoindex on;
index index.html index.htm index.php l.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php$ { //是php文件转交给127.0.0.1:9000处理
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE open_basedir=$document_root:/tmp/:/proc/;
include fastcgi_params;
}
}