【原】配置Nginx隐藏index.php和PathInfo的配置
in 备忘 with 0 comment

【原】配置Nginx隐藏index.php和PathInfo的配置

in 备忘 with 0 comment
server {
        listen       8080;
    root /opt/admin; 
        charset utf-8;
    index index.php index.html index.htm;

        #access_log  logs/host.access.log  main;
        #隐藏index.php
        location / {
            try_files $uri $uri/ /index.php$request_uri; 
    }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        # 配置PathInfo
        location ~ \.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
            try_files $fastcgi_script_name = 404;

        set $path_info $fastcgi_path_info;
            fastcgi_param PATH_INFO $path_info;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        include        fastcgi_params;
     }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.(ht|svn|git) {
            deny  all;
        }
}
Comments are closed.