I have lots of image files without an extension (no .png, .jpg, .etc) in the Wordpress uploads folder (/wp-content/uploads/2024/). These do appear in articles and are used, but due to the missing extension they're not cached and I suppose they hurt SEO a little too. Besides, not having an extension, browser tend to download them, not display them.
My question is, how to rewrite these URLs so that the site.com/wp-content/uploads/2024/image will load in the browser like this /wp-content/uploads/2024/image.jpg? To make things worse, there are also image that have only the DOT (.) at the end, without the extension, and all these are mixed together with the valid one, images with .jpg, .png, . webp. In a word, mess.
While ideally changing the database and the adding the file extension should be preferred, it is not something easily done. So I'd rather use a rewrite rule to keep things simple and doable.
The /wp-content/uploads/2024/ has only images, so I'm thinking of 2 rewrite rules, but cannot put them on paper: one to check if the file doesn't have an extension, then the rule another to check if the file end in (.), then rewrite
Please help
.jpg/.jpeg, nginx sends MIME type for JPEG image. I would always take the effort to fix this properly. Adding such a redirect layer will only make the setup more unstable.