How to disable "Uppercase URLs are redirected to Lowercase URLs" feature?

  • Hexo Site: pil0txia.netlify.app

  • Problem URL: https://pil0txia.netlify.app/post/2020-09-02_Angel-Beats!/

Google Search Console notified me that this URL has index problems (Failed: Redirect Error) (Page Indexing report - Search Console Help).

The URL I specified in sitemap is https://pil0txia.netlify.app/post/2020-09-02_Angel-Beats!/ ,which has uppercase characters. Netlify will automatically rewrite/redirect https://pil0txia.netlify.app/post/2020-09-02_Angel-Beats!/ to https://pil0txia.netlify.app/post/2020-09-02_angel-beats!/ . However, the redirect won’t happen when I deployed my Hexo site to OSS+CDN (for example Backblaze B2 + Cloudflare) and I prefer the latter.

I didn’t enable Asset Optimization/Pretty URLs or netlify.toml. Please tell me how to solve it. Thanks a lot!

Hi @Pil0tXia,

Thanks for reaching out!

I found this Netlify forum post on a similar issue:

Let us know if you have any questions.

No, I didn’t set any netlify.toml file. I want to disable any redirect and keep my URLs with uppercase. May you please tell me how to do it?

Netlify automatically normalises URLs to lowercase and there’s no way to disable it.

Is there anything I can do?

I don’t believe so, sorry.

I only just found this out. This is a mistake. We should be completely in control of the casing of our resources. I have a bunch of 301 redirects that Google doesn’t like because my Sitemap and links all over the internet uses the correct casing, but you guys redirect to lower-case. We really need to be able to disable this, please.

Hi, @kluplau. In my testing, my own site hosted on Netlify is not forcing a redirect to all lower case at this time.

What URL is this happening for in your own testing?

Netlify automatically normalises URLs to lowercase and there’s no way to disable it.

Redirecting URLs seems like a bad default, and even worse if it’s not a setting. Our application’s back-end uses case-sensitive paths, and when these are transformed, we get 404s from our back-end. Completely breaks our service, as some resources have case-sensitive URLs (which should be OK according to the URL spec)

Many apps use NanoID, for example. These would all break if I’m understanding this correctly.

We do that only for static files. Rewrites to other sites, Netlify Functions, etc. should work in case-insensitive manner.

Hugo supports a config option that addresses this problem:

disablePathToLower = true

Based on my testing, Netlify apparently does not respect this feature. To fix the underlying option, perhaps Netlify should support the option that Hugo supports.

This is not expected to change (it’s not a bug): Bug in Production Download - #8 by hrishikesh

In your answer in the linked post you said:

Based on what you’ve said above

The likelihood of Netlify re-evaluating it’s position is minute at best.

@promer Cloudflare Pages supports lowercase, UPPERCASE, and MiXeDcAsE for paths (the lowercase path exists, but doesn’t force a redirect). Perhaps this is an option for your situation. Here’s the Hugo deploy guide

Thanks to hrishhikesh. It is helpful for everyone to have clarity about what to expect.

Thanks also for the suggestion that I look at Cloudflare. I’ve been happy with Netlify and this particular issue has never come up before, but I’ve recently found that it would be helpful to have a page with a URL that this forum won’t let me display. I’ll give it in two pieces: Concatenate:

https://paulromer.net

“/F4qzRqQSe6FRCdhxBcMCdhYnDg8fwz4WijxHGCnXCvY=”

If you click through you will see why I want this URL. You will get to the right page because of a redirect to the page with the lowercaseed version of the URL. But as the content of the page makes clear, the URL (which is URLsafe Base64) has meaning and the meaning changes radically if you change the case.

Hi, @promer. Netlify won’t change the case for GET parameters but will for path segments.

I know that it is less than ideal but, only as a workaround, would it be possible to change the URL from this:

https://paulromer.net/F4qzRqQSe6FRCdhxBcMCdhYnDg8fwz4WijxHGCnXCvY=

To something like this instead?

https://paulromer.net/?public_key=F4qzRqQSe6FRCdhxBcMCdhYnDg8fwz4WijxHGCnXCvY=

Please note, you could still have the file at the original location and redirect to that file with this redirect in _redirects format:

/ public_key=:id  /F4qzRqQSe6FRCdhxBcMCdhYnDg8fwz4WijxHGCnXCvY=  200!

I know you would prefer the path not be normalized to all lower-case and this is the only workaround I see at this time.

Luke,

Thanks for the suggestion. In short, yes, it would be a good solution.

I tried to write back once before but didn’t format the links correctly, so my reply got caught in the spam filter; in fairness to the filter, it did look pretty spammy.

In any case, if I understand correctly, I can tell people to use this request:

https://paulromer.net/?public_key=F4qzRqQSe6FRCdhxBcMCdhYnDg8fwz4WijxHGCnXCvY=

With the redirect, I think they will see the not-normalized version of the path in the URL bar, like this:

https://paulromer.net/F4qzRqQSe6FRCdhxBcMCdhYnDg8fwz4WijxHGCnXCvY=

Let me know if I’ve misunderstood or if there is anything I should do differently in terms of what I tell Hugo the URL for the page should be.

I should be able to test the redirect in a couple of days and will report back.

Hi, @promer. They would see the URL with the ? in it but access token will still be the end of the URL. It will show the content for the https://paulromer.net/F4qzRqQSe6FRCdhxBcMCdhYnDg8fwz4WijxHGCnXCvY= page but the ? will be in the URL in the browser’s address bar.

Thx!

I’m still a little bit unsure about how this will work.

But instead of wasting your time, let me see if I can get the redirect to work. If so, I’ll be able to see exactly what any user will see.

@promer What is suggested by @luke would result in:

Browser URL
https://paulromer.net/?public_key=F4qzRqQSe6FRCdhxBcMCdhYnDg8fwz4WijxHGCnXCvY=

File Contents Returned
https://paulromer.net/F4qzRqQSe6FRCdhxBcMCdhYnDg8fwz4WijxHGCnXCvY=