# Rewrite utf8 : why lower case

**URL:** <https://www.ruby-forum.com/t/rewrite-utf8-why-lower-case/235145>\
**Category:** NGINX\
**Created:** [June 2, 2013, 3:33pm UTC](https://www.ruby-forum.com/t/rewrite-utf8-why-lower-case/235145 "2013-06-02T15:33:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [June 2, 2013, 3:33pm UTC](https://www.ruby-forum.com/t/rewrite-utf8-why-lower-case/235145/1 "2013-06-02T15:33:54Z")

</div>

Hi

I have some routes that was previously with uppercase for language and  
now I want lowrcase. here is a route : /Ka/განცხადებები that should  
simply become /ka/განცხადებები

in my conf if ($uri ~ ^/K(.+)){ set $bb $1; rewrite ^(.\*)$  
$scheme://$host/k$bb permanent; }

and I cant understand why but  
/ka/%E1%83%92%E1%83%90%E1%83%9C%E1%83%AA%E1%83%AE%E1%83%90%E1%83%93%E1%83%94%E1%83%91%E1%83%94%E1%83%91%E1%83%98/

become

/ka/%e1%83%92%e1%83%90%e1%83%9c%e1%83%aa%e1%83%ae%e1%83%90%e1%83%93%e1%83%94%e1%83%91%e1%83%94%e1%83%91%e1%83%98

ie all uppercase letter become lowercase, that cause à pb with my rails  
app.

does anyone know why nginx do this ? and is it possible to block this ?

I can’t just uppercase everything as there is some latin letter and my  
routes are case sensitive

thanks

Une messagerie gratuite, garantie à vie et des services en plus, ça vous  
tente ?  
Je crée ma boîte mail [www.laposte.net](http://www.laposte.net)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 2, 2013, 4:08pm UTC](https://www.ruby-forum.com/t/rewrite-utf8-why-lower-case/235145/2 "2013-06-02T16:08:23Z")

</div>

On Sun, Jun 02, 2013 at 03:33:34PM +0200, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

Hi there,

> ie all uppercase letter become lowercase, that cause à pb with my rails app.
> 
> does anyone know why nginx do this ? and is it possible to block this ?

As I understand it: %AA and %aa are exactly equivalent in a url. nginx  
rewrite has to pick something, and chooses to use lowercase. I don’t  
think there is a config-file way to control this.

(AA and aa are different; but the percent encoding is case-insensitive.)

You could try patching your nginx to make it choose to use uppercase,  
but that is unlikely to be very useful going forward.

The best I can suggest is that if your rails app handles %AA and %aa  
differently, that’s a bug in your rails app that might be easier for  
you to fix.

> I can’t just uppercase everything as there is some latin letter and my routes  
> are case sensitive

urls are case-sensitive _after_ the %-decoding has happened.

Before %-decoding, “%2E”, “%2e”, and “.” are all equivalent, so requests  
for “/a.png”, “/a%2Epng”, and “/a%2epn%67” should be handled  
identically.

Can you get your rails app to only consider the after-decoding request  
“/ka/განცხადებები” for routing?

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
