nginx 配置虚拟机 支持pathinfo

server {
        server_name shopx.local *.shopx.local;
        charset utf-8;
        root /Users/x/www/php/shopx.local/shopx/public;
        #让浏览器缓存静态文件
        location ~ .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|js|css)$
        {
            expires      30d;
        }
        location / {
            index  index.html index.htm index.php;
             if (!-e $request_filename) {
                rewrite ^/(.*)$ /index.php/$1;
            }
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
        location ~ /\.ht {
            deny  all;
        }
}

宝塔nginx项目配置

server
{
    listen 80;
    server_name thankdom.com www.ydshopv1.thankdom.com admin.ydshopv1.thankdom.com api.ydshopv1.thankdom.com m.ydshopv1.thankdom.com shop.ydshopv1.thankdom.com;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/ydshopv1/public;
    
    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    #SSL-END
    
    #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
    error_page 404 /404.html;
    error_page 502 /502.html;
    #ERROR-PAGE-END
    
    #PHP-INFO-START  PHP引用配置,可以注释或修改
    include enable-php-72.conf;
    #PHP-INFO-END
    
    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    include /www/server/panel/vhost/rewrite/thankdom.com.conf;
    #REWRITE-END
    
    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }
    
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        access_log off; 
    }
    
    location ~ .*\.(js|css)?$
    {
        expires      12h;
        access_log off; 
    }
    access_log  /www/wwwlogs/thankdom.com.log;
    error_log  /www/wwwlogs/thankdom.com.error.log;
}

nginx伪静态

location / {
     if (!-e $request_filename) {
          rewrite ^/(.*)$ /index.php/$1;
     }
}
posted @ 2018-03-13 21:52  geek程序员  阅读(303)  评论(0编辑  收藏  举报