简单配置nginx使之支持pathinfo(nginx配置dist)


1.pathinfo参考,复制全部,修改域名目录等
server {
    listen 80;
    server_name   xx.shnne.com;
    access_log    /xx/xx/xx/access_shnne.log;
    root /xx/xxx/shnne;

  location /  {
     index index.php index.html;
          if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?s=/$1  last;
            break;
          }
  }


  location ~* \.php {
      fastcgi_pass  unix:/tmp/php-fpm.socket;
      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;
   }
}

或者
server {
    listen 80;
    server_name   xx.shnne.com;
    access_log    /xx/xx/xx/access_shnne.log;
    root /xx/xxx/shnne;

  location /  {
     index index.html index.php;
  }

  if (!-e $request_filename) {
    rewrite ^/(.*)  /index.php/$1 last;
  }

  location ~ .+\.php($|/) {	#修改这里
      fastcgi_pass  unix:/tmp/php-fpm.socket;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME $document_root/$fastcgi_script_name;
      include        fastcgi_params;
   }
}




2.伪静态url重写
server {
  listen 80;
  server_name www.shnne.com;
  access_log    /data/log/nginx/access_shnne.log;
  root /data/web/shnne/public;
  location /  {
     index index.php index.html;
  }

  location ~* \.php$ {
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME $document_root/$fastcgi_script_name;
      include        fastcgi_params;
   }

    if (!-e $request_filename) {
     rewrite ^/(.*\.(js|ico|gif|jpg|png|css|bmp|html|xls)$) /$1 last;
     rewrite ^/(.*)  /index.php?$1 last;
    }
}


标签:

上一篇nginx配置owncloud时候的配置文件(nginxclientallow怎么配置)
下一篇php安装mysqli扩展(php安装扩展的几种方法)

相关文章