2015-08-31 35 views
0

這看起來很基本,但我無法解決這個問題。 我想NGINX服務於當前根外源的URL,基本符合../如何從NGINX的根目錄以外提供相對源url

開始這是我的目錄

common 
root (NGINX root) 
    ->index.html (NGINX default index) 
    common (another common folder) 

我希望能夠以服務

src="../common/whatever" /*outer common folder*/ 
src="./common" /*inner common folder; Cannot change unfortunately*/ 

正如你所看到的,簡單location /common將無法​​正常工作。

這是我目前NGINX的conf,

server 
{ 

    listen 83 default_server; 
    listen [::]:83 default_server ipv6only=on; 

    root C:/www/root; 
    index index.html index.htm; 

    #This does not work for inner /common folder 
    location /common { 
    root C:/www; 
    try_files $uri /index.html; 
    } 

    location/{ 
    try_files $uri /index.html; 
    } 
} 

回答

1

也許你可以做反向:

root/ 
    common/* 
    site/ 
    site/common/* 

,並完成類似

location /common { 
    try_files site/$uri $uri ...; 
} 

等等,讓你$root/site/common/FILE, $root/common/FILE...

相關問題