2016-04-07 16 views
0

如果有人訪問我的主頁/索引頁,我需要服務器我的index.html文件。但是,如果它是另一個URL /路徑將請求傳遞給我的index.php文件(我正在使用Symfony)。如何用PHP文件爲我的主頁提供HTML文件和所有其他路徑/網址

我按照this example,但不工作。它總是在服務我的PHP文件。

server 
{ 
    listen  80; 
    server_name mysite.com; 

    root /path/to/my/web; 
    index index.html index.php; 

    location = /index.html 
    { 
     try_files $uri /index.html?$args; 
    } 

    location/
    { 
     try_files $uri /index.php?$args; 
    } 

} 

我會感謝任何幫助或指導,你可以與我分享。

回答

0

這終於爲我工作:

server 
{ 
    listen  80; 
    server_name mysite.com; 

    root /path/to/my/web; 
    index index.html index.php; 

    location =/
    { 
     try_files $uri /index.html?$args; 
    } 

    location/
    { 
     try_files $uri /index.php?$args; 
    } 

} 
相關問題