How nginx matches different static resource directories based on paths
给我你的怀抱
给我你的怀抱 2017-05-16 17:07:51
0
1
681

How nginx matches different static resource directories based on paths

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;
}

I hope that when the path contains console, a special static resource directory is accessed, and everything else is obtained from another one. I don’t know how to write the configuration file

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

reply all(1)
黄舟

You can take a closer look at some configurations of nginx regarding location and provide a method

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

location ~* \.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
    root /dist;
    expires  30d;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!