zoukankan      html  css  js  c++  java
  • nginx下配置nginx.conf支持pathinfo模式

    之前用的都是Apache做webserver从没碰到过pathinfo的问题,自从接触了nginx刚好项目又是用ci框架做的,刚装好就碰到pathinfo未配置导致的页面404错误。

    长话短说,下面我贴上配置代码

    nginx.conf中sever段配置

    server
        {
            listen 80 default_server;
            #listen [::]:80 default_server ipv6only=on;
            server_name www.lnmp.org;
            index index.html index.htm index.php;
            root  /home/wwwroot/default;
    
            #error_page   404   /404.html;
            include enable-php-pathinfo.conf;
    
            location /nginx_status
            {
                stub_status on;
                access_log   off;
            }
    
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
            }
    
            location ~ .*.(js|css)?$
            {
                expires      12h;
            }
    
            location ~ /.
            {
                deny all;
            }
    
            access_log  /home/wwwlogs/access.log;
        error_log /home/wwwlogs/error.log error;
        }
    include vhost/*.conf;
    }
    enable-php-pathinfo.conf 配置内容
    location ~ [^/].php(/|$)
            {
                fastcgi_pass  unix:/tmp/php-cgi.sock;
                fastcgi_index index.php;
                fastcgi_split_path_info ^(.+?.php)(/.*)$;
                set $path_info $fastcgi_path_info;
                fastcgi_param PATH_INFO       $path_info;
                try_files $fastcgi_script_name =404;
                include fastcgi.conf;
                
            }
     
  • 相关阅读:
    django模型系统(二)
    css基础
    css进阶
    django模型系统(一)
    自定义过滤器及标签
    django模板标签
    模板变量及模板过滤器
    第六章 异常
    第三章:多态
    第三章:提高系统性能:从数据访问开始
  • 原文地址:https://www.cnblogs.com/blueVirus/p/5580700.html
Copyright © 2011-2022 走看看