nginx设置子域名都跳转到www域名下

方法1: 域名解析时设置泛解析

方法2:nginx配置:

server {  
    listen 80; 
    server_name apkfuns.com *.apkfuns.com www.apkfuns.com; 
    if ($host != "www.apkfuns.com") { 
        rewrite ^/(.*)$ http://www.apkfuns.com/$1 permanent; 
    } 
}

设置完别忘了重启服务器 service nginxd restart