function rateConfig()
{
return [
1 => 0.397,
2 => 0.400,
3 => 0.203,
];
}

function randRate()
{
$rateConfig = rateConfig();
foreach ($rateConfig as $k => $v) {
$rateConfig[$k] = $v * 10000;
}

//概率数组的总概率精度
$proSum = array_sum($rateConfig);

//概率数组循环
foreach ($rateConfig as $key => $proCur) {
$randNum = mt_rand(1, $proSum);
if ($randNum <= $proCur) {
$result = $key;
break;
} else {
$proSum -= $proCur;
}
}
unset ($proArr);
return $result;
}

server
{
listen 80;
server_name xx.com;
index index.html index.php;
root /www/xx.com;

location /
{
index index.php;
if (!-e $request_filename) {
#多入口这几行也不需要
#rewrite /admin.php(.*)$ /admin.php$1 last;
#rewrite ^(.*)$ /index.php/$1;
#break;
rewrite ^/(.*)$ /index.php?s=$1 last;
}
}
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
#try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi5.6.sock;
fastcgi_index index.php;
include fastcgi.conf;
#注意pathinfo.conf不需要
#include pathinfo.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

access_log off;
}