Nginx配置支持rewrite

server {

    listen       80;
    server_name  localhost;

    #charset koi8-r;
    access_log  /data/logs/yyy.access.log  main;   #访问日志
    error_log  /data/logs/yyy.error.log;  #错误日志

    root /data/www.yyy.com/public;     #项目的总目录
    index index.php index.html index.htm index.shtml;   #访问首页

    location / {
        root /data/www.yyy.com/public;    
        index index.php index.html index.htm index.shtml;

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

    location ~ \.php$ {
        root           /data/www.yyy.com/public;
        fastcgi_pass   172.19.0.2:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /data/www.yyy.com/public/$fastcgi_script_name;
        include        fastcgi_params;
    }

}

http://www.thinkphp.cn/code/1402.html

posted @ 2020-03-01 23:54  小萍瓶盖儿  阅读(139)  评论(0)    收藏  举报