1

According to this answer, the directive:

try_files $uri.html $uri/ =404;

Is supposed to make it so that

only one copy of the resource is served (that with no .html extension)

However, I have this directive in my config:

 server {
  listen 443 ssl default_server;
  listen [::]:443 ssl;

  server_name waynewerner.com www.waynewerner.com;

  ssl_certificate       /etc/letsencrypt/live/www.waynewerner.com/fullchain.pem;
  ssl_certificate_key   /etc/letsencrypt/live/www.waynewerner.com/privkey.pem;

  index index.html;
  root /var/www/waynewerner.com/site/;
  try_files $uri.html $uri/ =404;

  location ^~ /blog {
    alias /usr/share/blog/output;
    break;
  }

  location /.well-known {
    allow all;
    root /var/www/;
  }

  location /.hg {
    deny all;
    return 404;
  }
}

But you'll notice that you can go to both:

(At least that's how they appear in my Google Chrome address bar).

Is this something to worry about, or is Nginx doing the right thing?

7
  • What exactly is your goal here? Having multiple URLs serving same content is bad for SEO. Jan 25, 2017 at 19:35
  • @TeroKilkanen the goal looks to be serving html files without the .html extension. Seems rather pointless to me personally. Installing Wordpress as most photographers do would be a good solution. With the try_files like that I'm surprised direct access to the html file works, I'd only have expected that if the try_files included $uri. In practice I don't think it'll matter so long as nothing links to the .html files so a crawler can't find it. However you've linked to it from this page so crawlers like Google can find it now.
    – Tim
    Jan 25, 2017 at 19:46
  • @TeroKilkanen that's exactly what the linked answer (well, this comment that produced that answer) says. My understanding is that it would do some kind of something, I don't know, rewrite? redirect? The answer doesn't specify. Wordpress is right out for a number of reasons - this site is a statically generated site. Presumably I could setup a redirect with nginx, though that wasn't specified as necessary in the other answers, so... Jan 25, 2017 at 21:15
  • either I'm wrong, or those comments/answers are. Jan 25, 2017 at 21:15
  • What is the reason that you want to hide .html extension? Jan 25, 2017 at 21:22

0

You must log in to answer this question.

Browse other questions tagged .