E.g., remi-theriault.netlify.app/cv won’t work without specifying .pdf (both the html and pdf are static files at the root of /static).
Right now I am using a Netlify redirect for each individual file but for many files, this can be a long process (and more maintenance). I wonder if there’s not an easier way to hide the file extension for all files and not just html? For example, in WordPress, I simply had to add “Options +MultiViews” at the top of my .htacces file. Thank you.
I see netlify there. You must add a content type to each URL that is NOT HTML or the server will assume HTML.
For PDF you need a header “Content-Type: application/pdf”.
Other than that: “Ugly/Pretty URLs” is a concept that has to do with the delivery of “websites” meaning ALWAYS HTML content. Everything else it “other” content. So there is no button-switch way to achieve that. If you want to output a PDF without having it in path/to/filename.pdf you will have to save it without file ending and force the content type for the browser.
Using redirects is the way. If said files live in a specific directory, you could create a wildcard redirect. Haven’t tested it, but something like:
/files/* /files/:splat.pdf
From a usability point of view, I believe it’s friendlier towards the end-users to keep the “.pdf” extention in the URL. Most desktop browsers nowadays have built-in viewers, but that’s not always the case, and many will be forced to download a file where they expect to visit a page.
I think it is a very bad practice in terms of user experience to remove file extensions (other than .html) from URLs. To be honest I have never seen this on any website before. I hope I never will.