iT邦幫忙

0

[nginx] 同域名不同 URL路逕PATH 批配不同專案目錄 備忘錄

  • 分享至 

  • xImage
  •  

sample.com/ ->指向 資料夾A
sample.com/web ->指向 資料夾B
sample.com/config.json 自動覆寫使用不同 json

    root /data/forder1;
    
    location = /web {
        return 301 /web/;
    }

    location ^~ /web/ {
        alias /data/forder2/;
        index index.html;
         try_files $uri $uri/ /index.html;
    }
    
    location = /config.json {
      if ($host ~* "^www\.sample\.com$|^sample\.com$") {
          rewrite ^ /config-sample.com.json last;
      }
      root /data/forder1;
    }

sample.com/ ->指向 資料夾A
sample.com/h5 ->指向 資料夾B
sample.com/h5/config.json 自動覆寫使用不同 json

    root /data/forder1;
    
    location = /h5 {
        return 301 /h5/;
    }

    location ^~ /h5/ {
        alias /data/forder2/;
        index index.html;
         try_files $uri $uri/ /index.html;
    }
    
    location = /h5/config.json {
       if ($host = "bax-max.com") {
            rewrite ^ /config-bax-max.com.json break;
        }
        root /data/forder2;
        try_files $uri =404;
    }

圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言