Case sensitivity with redirects

Hey everyone,

Are redirects listed in _redirects case-sensitive?

I’m having a minor issue with redirects.

The following URL redirects to twitter.com:
https://clever-benz-7901c5.netlify.com/twitter

However, the redirect completely fails if I type my URL in a different way:
https://clever-benz-7901c5.netlify.com/TWITTER

This is the exact code I’m using:
/twitter https://twitter.com

Am I missing something? I have Pretty URLs enabled.

Thanks!

The path component of an HTTP URL is case-sensitive; this is part of the standard. Thus, /twitter and /TWITTER are two different URLs, and you need to decide what you will serve (content, 404, etc.) for each one. A site might serve the same for both, but that would be a choice of the site developer.

As a side note, Netlify itself may do some case-changing for built-in redirections. I think I’ve even seen this with pretty URLs disabled (something like getting /Foo:Bar, redirecting it to /foo:bar and then serving /Foo:Bar.html for it) but I don’t recall all the details now.

1 Like

Is there any way to case-change all URLs using Netlify’s built-in redirections?

That’s a great answer @cjs, thanks!

When you use redirects, we don’t change the case and it is case-sensitive. If you need to match multiple cases then you’ll have to include separate redirect lines for each of those cases.