2013-02-18 24 views
-1

我正在關閉一個網站,我需要nginx將所有用戶重定向到根目錄,而不僅僅是在所有網站上向他們展示相同的頁面。如何告訴nginx將網站的所有頁面重定向到root?

現在我有這樣的:

server { 
    listen 80; 
    root /var/www/mysite; 
    rewrite ^.*$ /index.html last; 
} 

然而,這並不重定向,而是處處展示index.html內容。 我該如何做一個重定向,以便mysite.com/somepage將重定向到mysite.com,而這反過來會顯示index.html頁面?

回答

1

以下應該做你想要什麼:

server { 
    listen 80; 

    root /var/www/mysite; 
    location =/{ try_files /index.html = 404;} 

    location/{ rewrite ^/permanent; } 
} 
相關問題