删除nginx中的索引扩展

时间:2012-06-17 22:30:46

标签: nginx

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

1 个答案:

答案 0 :(得分: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应该尝试后端没有扩展名的文件

相关问题