Asian url redirection

43 Views Asked by At

I am trying to setup a redirection of URLs that contain Korean or Japanese characters to their English counterparts in a Sinatra application (ruby). Instead of a 301, I get a 404 response.

Example:

http://localhost/ko/blog/%ec%95%b1-%ec%a0%84%ed%99%98%ec%9c%a8%ec%9d%84-%eb%86%92%ec%9d%b4%eb%8a%94-%eb%b0%a9%eb%b2%95 
---> http://localhost/ko/blog/how-to-increase-your-rate

This does not redirect:

get "/ko/blog/%ec%95%b1-%ec%a0%84%ed%99%98%ec%9c%a8%ec%9d%84-%eb%86%92%ec%9d%b4%eb%8a%94-%eb%b0%a9%eb%b2%95" do
  redirect "/ko/blog/how-to-increase-your-rate", 301
end

Unsurprisingly (but I was desperate) decoding does not redirect either:

get "/ko/blog/앱-전환율을-높이는-방법" do
  redirect "/ko/blog/how-to-increase-your-rate", 301
end

When I look at the server log, the url requested is exactly this:

127.0.0.1 - - [15/Jun/2023:13:31:33 +0200] "GET /ko/blog/%ec%95%b1-%ec%a0%84%ed%99%98%ec%9c%a8%ec%9d%84-%eb%86%92%ec%9d%b4%eb%8a%94-%eb%b0%a9%eb%b2%95 HTTP/1.1" 404 - 0.0786

How can I get sinatra to recognize the requested url string ?

Update: the stack

  • Ruby 2.7.8
  • Sinatra 2.2.3
0

There are 0 best solutions below