资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

配置nginx使之支持pathinfo

phalcon项目,
oneinstack环境lnmp。
配置文件:
/usr/local/nginx/conf/vhost/dldh.ccc.conf
自动生成的。

目前成都创新互联公司已为1000+的企业提供了网站建设、域名、网页空间、成都网站托管、企业网站设计、芒康网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

问题:
除首页外,其他都打不开,且样式文件也打不开。
http://dldh.ccc/index.php/back/css/bootstrap.min.css
http://dldh.ccc/index.php/backend/index/index
都报: Access denied.

解决办法:
作修改如下。


server {
  listen 80;
  server_name dldh.ccc;
  access_log off;
  index index.html index.htm index.php;
  root /web/dldh/public;

  try_files $uri $uri/ @rewrite; #增加这一句
                    location @rewrite{  #增加这一句
        rewrite ^/(.*)$ /index.php?_url=/$1; #增加这一句
  }

  #include /usr/local/nginx/conf/rewrite/none.conf;#注释这一句
  #error_page 404 /404.html;
  #error_page 502 /502.html;

  location ~ [^/]\.php(/|$) {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    fastcgi_split_path_info ^(.+\.php)(.*)$; #增加这一句
    fastcgi_param PATH_INFO $fastcgi_path_info; #增加这一句
  }

  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
  }
  location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
  }
  location ~ /\.ht {
    deny all;
  }
}

参考:
nginx下支持PATH_INFO详解[1]
https://blog.csdn.net/hanzengyi/article/details/53483171
简单配置nginx使之支持pathinfo
https://www.cnblogs.com/kzfbk/p/7302623.html


分享名称:配置nginx使之支持pathinfo
文章网址:http://cdkjz.cn/article/ihpgpi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220