nginx如何根据路径匹配不同的静态资源目录
给我你的怀抱
给我你的怀抱 2017-05-16 17:07:51
0
1
683

nginx如何根据路径匹配不同的静态资源目录

location /console/ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
    root /opt/jenkins/workspace/little_garden_web/console;
    index /opt/jenkins/workspace/little_garden_web/console/index.html;
    expires      30d;
}

location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
    root /opt/jenkins/workspace/little_garden_web/dist;
    expires      30d;
}

我希望路径带console的时候访问一个特殊的静态资源目录,其他的都到另一个去获取,不知道配置文件该怎么写

给我你的怀抱
给我你的怀抱

全部回复(1)
黄舟

可以多看下nginx关于location的一些配置,提供一种方法

location ^~ /console/ {
    root /console;
    expires  30d;
}

location ~* \.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
    root /dist;
    expires  30d;
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!