使用Apache,特定vhost中的指令DirectoryIndex index
和DefaultType application/x-httpd-php
可以很好地从索引文件中排除文件扩展名而无需重写。我怎样才能在Nginx中复制这个?到目前为止,我所能找到的只是正则表达式重写解决方案。
答案 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
应该尝试后端没有扩展名的文件