nginx 多域名配置

 尕豆   2017-12-16 22:33   792 人阅读  0 条评论

//对个域名指向同一个目录,多域名之间空格间隔

server {
    listen       80;
    server_name  www.pgnote.com www.biaoqianye.com;
    index index.html index.htm index.php;
    root /alidata/www/www.pgnote.com;
    location ~ .*\.(php|php5)?$
    {
        #fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires 30d;
    }
    location ~ .*\.(js|css)?$
    {
        expires 1h;
    }
    include /alidata/server/nginx/conf/rewrite/wordpress.conf;
    access_log  /alidata/log/nginx/access/www.pgnote.com.log;
}

//301重定向(顶级域名重定向到www.***.com)
server{
    server_name pgnote.com;
    rewrite ^/(.*) http://www.pgnote.com/$1 permanent;
}

//二级、三级域名泛解析,自动解析目录名称为域名前缀

server {
    listen              80;
    server_name ~^(?<subdomain>.+)\.weilomo\.com$;
    location / {
        root  /data/htdocs_www/application/$subdomain;
        if (!-e $request_filename){
            rewrite ^(.*)$ /index.php/$1 last;
        }
        index index.html index.htm index.php;
    }
    location ~ \.php{
        root           /data/htdocs_www/application/$subdomain;
        fastcgi_pass   127.0.0.1:9000;
        include        fastcgi_params;
        fastcgi_index  index.php;
    }
}


本文地址:http://www.pgnote.com/?id=10
版权声明:本文为原创文章,版权归 尕豆 所有,欢迎分享本文,转载请保留出处!
 相关文章  关键词:

 发表评论


表情

还没有留言,还不快点抢沙发?