Configure nginx to support pathinfo

phalcon project,
oneinstack environment lnmp.
Configuration file:
/usr/local/nginx/conf/vhost/dldh.ccc.conf
is automatically generated.

Problem:
Except for the home page, the others cannot be opened, and the style file cannot be opened.
http://dldh.ccc/index.php/back/css/bootstrap.min.css
http://dldh.ccc/index.php/backend/index/index
both reported: Access denied.

Solution:
Make changes as follows.


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;
  }
}

Reference:
Detailed explanation of PATH_INFO support under nginx [1]
https://blog.csdn.net/hanzengyi/article/details/53483171
Simply configure nginx to support pathinfo
https://www.cnblogs.com/kzfbk/p/7302623. html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325299845&siteId=291194637