2016-09-15 6 views
1

私はそのURIを介して提供する変数htmlファイルをアーカイブしたい、以下は私の設定です。nginxは場所から複数のインデックスファイルを配信します

server { 
    listen 8888; 
    server_name localhost; 

    location/{ 
    root html/test 
    index foo.html 
    } 

    location /another { 
    root html/test 
    index bar.html 
    } 
} 

私はlocalhost:8888/anotherの要求はその後、私のテストディレクトリに存在bar.htmlを応答しますが、私は失敗しています:(

は、どのように私は設定上の修正ができ、感謝のお時間。

答えて

1

ファイル名はrootディレクティブとURIの値で構成されているので、この場合には:。

location /another { 
    root html/test; 
    index bar.html; 
} 

URI /another/bar.htmlは、html/test/another/bar.htmlにあります。

locationディレクティブの値を最初にURIから削除する場合は、aliasディレクティブを使用します。

location /another { 
    alias html/test; 
    index bar.html; 
} 

URI /another/bar.htmlhtml/test/bar.htmlに配置されます。

詳細はthis documentを参照してください。

+0

ご返信ありがとうございます。 –

関連する問題