server {
    server_name yubin.bid www.yubin.bid manage.yubin.bid forum.yubin.bid passport.yubin.bid upload.yubin.bid;

    listen 80;

    autoindex on;

    set $charset utf-8;

    charset $charset;

    set $rootdir /data/web/yubin.bid/web/application/plant;
    set $project www;

    if ( $host ~* "^([^\.]+)\.yubin\.bid" ) {
        set $project $1;
    }

    if ( $project ~* www ) {
        set $project main;
    }

    set $rewrite yes;

    if ( $request_uri ~* (assets\/|crossdomain\.xml) ) {
        set $rewrite no;
        set $rootdir /data/web/yubin.bid/web/package;
    }

    set $rootdir $rootdir/$project;
    root $rootdir;
    index index.php index.html;


    if ($rewrite ~* yes) {
        rewrite ^/(.*) /index.php/$1 last;
    }

    location ~ /(assets\/|crossdomain\.xml)
    {
        try_files $uri $uri/ /index.html;
    }


    location / {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        # With php5-cgi alone:
        #fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}


server {
    server_name file.yubin.bid assets.yubin.bid;

    listen 80;

    autoindex on;

    set $charset utf-8;

    charset $charset;

    set $rootdir /data/web/yubin.bid/web/data;
    set $project upload;

    if ( $host ~* "^([^\.]+)\.yubin\.bid" ) {
        set $project $1;
    }

    if ( $project ~* file ) {
        set $project upload;
    }

    set $rootdir $rootdir/$project;
    root $rootdir;
    index index.html;
    location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
    }

}