codeigniter在nginx安装配置及URL重写
产品需要使用ci框架能有优雅的uri方式,希望产品的服务器中间件有强悍的性能选择,我把ci的项目放到nginx上并去除index.php;
步骤一
//在application/config.config.php $config['uri_protocol'] = "PATH_INFO";
步骤二
修改nginx.conf
server { listen 80; listen [::]:80 ipv6only=on; server_name www.example.com; root /data/www/www.example.com; index index.php index.html index.htm; location / { # 这里使用try_files进行url重写,不用rewrite了。 try_files $uri $uri/ /index.php?$query_string; } location ~ \.php($|/) { 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 SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }