遇上了几个坑
首先 修改配置文件后
用 nginx -s reload 打死不生效(其实也不是不生效 只是老是不正常) 重启nginx后突然什么都好了
然后
$1的陷阱 rewrite也会使用$1 于是造成上面的$1被覆盖了 导致错误
只有把root那里使用的$1赋值给另外一个名字的变量
最后配置文件如下
server {
listen 80;
server_name ~^(.+)?.mx1985.com$;
set $active_root $1;
set $mio_root '/www/mx1985.com/$active_root';
root '/www/mx1985.com/$active_root';
access_log logs/mio_com_access.log;
error_log logs/mio_com_error.log;
index index.html index.php;
location ~ .html$ {
rewrite ^/mio([d]+).html$ /index.php?m=Content&id=$1 last;
rewrite ^/about.html$ /index.php?m=About last;
rewrite ^/list([d]+).html$ /index.php?m=List&id=$1 last;
rewrite ^/list([d]+)p([d]+).html$ /index.php?m=List&id=$1&page=$2 last;
rewrite ^/key([a-zA-Z0-9_-.x7f-xffs]+).html$ /index.php?m=Search&key=$1 last;
rewrite ^/([d]+)key([a-zA-Z0-9_-.x7f-xffs]+).html$ /index.php?m=Search&key=$2&page=$1 last;
}
location ~ .mio$ {
rewrite ^/Uiapi.mio$ /index.php?m=Uiapi last;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $mio_root$fastcgi_script_name;
include fastcgi_params;
}
}
上一篇:加载了CSS但是样式出不来 下一篇:快递查询API