All of my static HTML file have no extension, meaning they are not index.html
, they are just index
. How can I tell Nginx to access them and deliver them as HTML files? I have the following configuration.
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
include snippets/snakeoil.conf;
root /home/davidgatti/Documents/example.com;
index home
server_name example.loc;
location / {
default_type text/html;
try_files $uri $uri $uri/ =404;
}
}
Right now Nginx sends back a 404
.
Eventually I figure it out:
index /home;
needs a slashtry_files
needs $uri.html
not sure why, but without it won't work.#
# Server Configuration
#
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
#
# Use the a default SSL for development.
#
include snippets/snakeoil.conf;
#
# Tell which folder to server.
#
root /home/davidgatti/Documents/Retireryte/YOUR_SITE_NAME/_output;
#
# Set the default file.
#
index /home;
#
# Tell Nginx which url is this configuration for.
#
server_name login.example.loc;
#
# Default configuration.
#
location / {
#
# Since we deliver files with no extension, we need to tell
# Nginx what those files are.
#
default_type text/html;
#
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#
try_files $uri $uri.html $uri/ =404;
}
}