2012-05-29 63 views
1

我將nginx設置爲一種靜態文件服務器。出於某種原因,它只在123.123.123.123/或123.123.123.123時才起作用。但是,當我去123.123.123.123/static/content/或123.123.123.123/static/content/another.mp3它返回一個404找不到。這是配置文件位於/etc/nginx/sites-available並鏈接到/etc/nginx/sites-enabled。我真的難住爲什麼它不工作。Nginx配置文件只適用於''/'

任何指針或建議,將不勝感激。

 
server { 
    listen 123.123.123.123:80; 
    server_name ""; 

    location/{ 
     root /srv/homepage; 
     index index.html; 
    } 

    location /static/content/ { 
     root /srv/static/content; 
     index song.mp3; 
    } 

} 

回答

2

看原木。 似乎LIK Ënginx的嘗​​試打開像/srv/static/content/static/content/file.mp3 路徑這裏需要重寫URL,試試這個:

重寫/static/content/(.*)/ $ 1間隔;

+1

如果我的應用中有很多鏈接/靜態頁面?我是否需要爲每個人重寫網址? –