温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

配置nginx使之支持pathinfo

发布时间:2020-10-24 14:50:30 来源:网络 阅读:1026 作者:phpervip 栏目:建站服务器

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

问题:
除首页外,其他都打不开,且样式文件也打不开。
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

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI