让ngixn 支持Ci路由跳转(pathinfo模式 )
让ngixn 支持Ci 路由跳转(pathinfo 模式 )在nginx 环境下访问的ci ,只能这种格式:http://localhost/index.php?c=home&m=view 如果使用:
让ngixn 支持Ci 路由跳转(pathinfo 模式 )
在nginx 环境下访问的ci ,
只能这种格式:http://localhost/index.php?c=home&m=view 如果使用:http://localhost/index.php/home/view/ 就报404错误
后来总结规律发现,只要http://localhost/index.php/ ; 后面带/ 就会出现404,
也就是说http://localhost/index.php 这个地址可以访问, 而http://localhost/index.php/ ; 就404
出现这样的情况需要通过以下两个步奏解决:
1:是因为 /usr/local/nginx/conf/vhost 的 ****.conf 没有配置好(***.conf即虚拟主机即伪静态管理文件)
(1)在shell 终端键入
cd /usr/local/nginx/conf/vhost

(2)找到对映网站的.conf 配置文件 在终端键入 vi ****.conf
,


图片中的代码如下:
server
{
listen 80;
#listen [::]:80;
server_name 192.168.1.12;#网站域名
index index.html index.htm index.php default.html default.htm default.php;
,root /home/linkai/mylove;#你的网站根目录
#include discuz.conf;
#error_page 404 /404.html;
location / {
index index.html index.htm index.php; if ($request_filename !~
(js|css|images|png|jpg|gif|robots/.txt|index/.php.*) )
{
#注意此处
rewrite ^/(.*)$ /index.php last;
#在以往的 windows环境下或apache 环境下 是rewrite
^/(.*)$ /index.php/$1 last;此处没有“/$1” ,改区别最为关键
break;
}
}
location ~ [^/].php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
,try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php;
nclude fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*.(js|css)?$
{
expires 12h;
}
access_log off;
}
(3):按下 esc键,再键入 :wq!保存退出
二:在终端键入:
vi /usr/local/php/etc/php.ini
,将cgi.fix_pathinfo=0 修改为cgi.fix_pathinfo=1 按下 esc键,再键入 :wq!保存退出