2012-06-17 68 views
0

在Apache中,指令DirectoryIndex index以及DefaultType application/x-httpd-php在特定的虛擬主機中工作良好,可以很好地從索引文件中排除文件擴展名,而無需重寫。我如何在Nginx中複製它?到目前爲止,我所能找到的就是正則表達式重寫解決方案。刪除nginx中的索引擴展

+0

您的問題已回答[http://stackoverflow.com/沒有擴展名的文件問題/ 7760883/nginx-setting -a-default-file-extension](http://stackoverflow.com/questions/7760883/nginx-setting-a-default-file-extension) – gabeio

+0

關閉,但不,它不'噸。該解決方案將要求該文件被命名爲index.php。我期待從前端和後端刪除擴展名。 – Isius

回答

0

.conf文件將是這個樣子:

server { 
server_name example.com; 

# Set the docroot directly in the server 
root /var/www; 

    # Allow index.php or index.html as directory index files 
    index index; 

    # See if a file or directory was requested first. If not, try the request as a php file. 
    location/{ 
     try_files $uri $uri/; 
    } 
} 

try_files $uri應儘量在後臺