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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: