Matching non ASCII characters in NGiNX location

If you need to match a non ASCII string with NGiNX, and don’t want to use the encoded URL, you can use this trick,

location ~* (*UTF8)^/אודות$ { 
    return 301 "https://blog.rabin.io/about-me"; 
}

Resources

  • http://stackoverflow.com/questions/28055909/does-nginx-support-raw-unicode-in-paths
  • http://serverfault.com/questions/656096/rewriting-ascii-percent-encoded-locations-to-their-utf-8-encoded-equivalent

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *