Archive | August 2010

Nginx, Passenger, and UTF-8 in Urls

A while ago I upgraded Nginx and moved from mongrel to passenger on my companies rails cluster. Our application has a url canonocalization enforement which will redirect urls to the cirrect url if they get mangles in any way.

The mangled url http://realtravel.com/h-178793-paris_hotel-kk

Will get redirected to the conanocal form: http://realtravel.com/h-178793-paris_hotel-kk_hotel_cayré

This enforcement is done with a check to make sure that the current url matched a newly generated one.

When I upgraded nginx and started using passenger the urls I was getting inifinate redirects because passenger encodes the UTF-8. THe fix was easy, but I was a bit surprised that the urls would not be decoded by default.

URI.decode('http://realtravel.com/h-178793-paris_hotel-kk_hotel_cayr%C3%A9')

Redirects are now fixed.

Advertisements