nginx泛域名解析
在dns做一条泛指到主机上,利用nginx做二级域名的rewirte
例如music.afen.cn/index.php?id=1转到www.afen.cn/music/index.php?id=1
server {
listen 80;
server_name www.afen.cn;
access_log off;
root /usr/www/afen/;
location / {
index index.php index.html index.htm;
}
}
server {
server_name ~^(.*)\.afen\.cn$;
set $name $1;
rewrite ^ http://www.afen.cn/$name$request_uri ;
}
博主,有个问题想请教下。我在/etc/hosts声明一个域名,如 main.com,我想用nginx如何实现 xxx.main.com 访问不同的二级域名,例如iteye的二级域名 http://flowercat.iteye.com/blog/633743。 我暂时是用的 nginx1.4+tomcat. 谢谢!