nginx如何根據路徑匹配不同的靜態資源目錄
给我你的怀抱
给我你的怀抱 2017-05-16 17:07:51
0
1
684

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學習者快速成長!