0

I'd like to redirect a following redirect in Nginx and I think its due to the encoding it has.

I have tried the below code and it doesn't work:

The redirect is:

From Test.com/hub/東京 To Test.com/home,

I encoded this with UTF-8 first, I also tried pasting it as is, but didn't work.

rewrite "^/hub/東京" "/home/" redirect;

rewrite "^/hub/%E6%9D%B1%E4%BA%AC%2F%20" "/home/" redirect;

Thank you in advance!

5
  • I tested your first rewrite and it works as expected. The second one will not work as rewrite does not see the URL-encoded form. Nov 29 at 15:03
  • Thanks Richard, I'll try again but not sure why it isn't working, would this make a difference if I added it like this as well: rewrite "^/hub/東京/?$" "/hub/" redirect; Nov 29 at 15:13
  • So, with or without a trailing /? That looks fine. Look at the access and error logs - the access log will have the URL-encoded form. Use nginx -T (uppercase T) to view the entire configuration across all included files and ensure that your rewrite is present. Enable the rewrite_log and ensure that your error log is logging notice level reports. Nov 29 at 17:07
  • With the trailing /. Thank you for the guidance I'll take a look at those logs too. Nov 30 at 9:59
  • For some reason none of these work :/ could it be the encoding, nginx -t shows that the syntax is fine but not that the actual redirect is following/working. 19 hours ago

0

You must log in to answer this question.