技术饭
nginx设置目录转发
nginx设置目录转发,很多时候项目只有一个域名,但是项目又有很多的入口,比如后台、数据运营后台、前台等,这种处理方式要么是几个二级域名,要么就是同一个域名做不同目录下的分发,当然同一个域名相对简洁,没那么的复杂,只要做一个nginx目录转发即可。
server {
#重定向后台目录
location /admin/ {
root /manyidea/gitwww/admin;
location ~ ^/pddadmin/.*\.(gif|jpg|jpeg|png|bmp|swf|flv)?$ {
root /manyidea/gitwww/admin;
expires 30d;
access_log off;
}
location ~ ^/pddadmin/.*\.(js|css)?$ {
root /manyidea/gitwww/admin;
expires 1h;
access_log off;
}
}
#重定向移动端目录
location /wap/ {
root /manyidea/gitwww/wap;
location ~ ^/wap/.*\.(gif|jpg|jpeg|png|bmp|swf|flv)?$ {
root /manyidea/gitwww/wap;
expires 30d;
}
location ~ ^/wap/.*\.(js|css)?$ {
root /manyidea/gitwww/wap;
expires 1h;
}
}
#重定向后台目录移动端
location /www/ {
root /manyidea/gitwww/www;
location ~ ^/sponsor/.*\.(gif|jpg|jpeg|png|bmp|swf|flv)?$ {
root /manyidea/gitwww/www;
expires 30d;
}
location ~ ^/sponsor/.*\.(js|css)?$ {
root /manyidea/gitwww/www;
expires 1h;
}
}
}


文明上网理性发言!