I want nginx to run /filename rendered as html file, /folder/ as folder (I mean loading /folder/index.html), and /filename.html as html file.
With default setup /filename not working. When I put a file as /filename to the server, it downloads the file.
I dont want any redirects, just load the files without trailing slash.
My current setup is
location / {
try_files $uri @proxy;
}
CodePudding user response:
Try adding default_type text/html;
to your server configuration.
Details of my test:
server {
server_name www.example.com;
root /var/www/example.com;
default_type text/html;
}
Test directory structure:
├── afile ├── afile.html └── afolder └── index.html
afile:
<html>
<b>html with no extension</b>
</html>
afile.html:
<html>
<b>html with an html extension</b>
</html>
afolder/index.html
<html>
<b>index.html</b>
</html>