删除nginx中的索引扩展

删除nginx中的索引扩展,nginx,Nginx,使用Apache,特定vhost中的DirectoryIndex指令以及DefaultType application/x-httpd-php可以很好地从索引文件中排除文件扩展名,而无需重写。如何在Nginx中复制此内容?到目前为止,我所能找到的只是正则表达式重写解决方案。该.conf文件如下所示: server { server_name example.com; # Set the docroot directly in the server root /var/www; # A

使用Apache,特定vhost中的DirectoryIndex指令以及DefaultType application/x-httpd-php可以很好地从索引文件中排除文件扩展名,而无需重写。如何在Nginx中复制此内容?到目前为止,我所能找到的只是正则表达式重写解决方案。

该.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一行应该在后端尝试没有扩展名的文件

您的问题已经得到了很好的回答,但是没有。该解决方案需要将文件命名为index.php。我希望删除前端和后端的扩展。