2014-06-20 129 views
0

基於某些條件,例如,基於User-Agent,我想確定默認索引頁面。在IF條件下,我無法使用index關鍵字。我該怎麼做才能做到這一點?任何幫助表示讚賞。Nginx默認索引頁面重定向

最新通報

我能解決這個問題,默認指數index.htm

和規則

location /index.htm { 
    if ($SOME_CONDITION = true) { 
     rewrite^/mindex.htm; 
    } 
} 

我不知道,這是否是正確的做法。如果這個問題有更好的解決方案,請加起來。提前致謝。

回答

0

你可以做這樣的事情

if ($http_user_agent ~* (googlebot|bingbot)) { 
      rewrite ^(.*)$ /index.html last; 
}