Wondering if anyone with some nginx experience could help me out with a rewrite rule issue I'm having.
I want to remove .html and trailing slashes from my URLs, so I put the following code in the server { } block in the nginx conf.d file:
error_page 404 404.html;
rewrite ^(/.+)\.html$ $1;
rewrite ^/(.*)/$ /$1 permanent;
try_files $uri.html $uri/ =404;
This works great, but it's broken the images on my site. I have them in a folder Images, so in my HTML it's like <img src="Images/someImage.jpg">
. They used to show up fine prior to adding the rewrite code, but now they don't load, and when I inspect them the Chrome console says "Failed to load resource: net::ERR_TOO_MANY_REDIRECTS", and beside that it says http://example.com/Images/404.html
If anyone knows what I'm doing wrong here, and could point me in the right direction, I'd greatly appreciate it!