I'm using AWS–s3 for static website hosting, and running it through Cloudflare services (including DNS). It is SEO best practice to truncate the .html
from URL names, while simultaneously avoiding duplicate content. I was achieving the desired result using nginx, and am wondering if it is even possible using either s3 or Cloudflare. My gut tells me no.
The basic requirement is: example.com/about.html
should rewrite (not redirect) to example.com/about
. The file name stored on s3 should remain, obviously, *.html
.
The one hack I've stumbled across is:
- Change the file name on the server to
about
(without the file extension). - Then, in the s3 console, change the metadata
content-type
back totext/html
.
I view this as a horrible "solution": Visiting *.html
results in a 404. Unless, of course, you create a duplicate file with the .html
extension, and then possibly create a url forwarding rule in Cloudflare. Not only is it very messy, it just plain doesn't scale.
Is there a better way?