本文介绍了nginx重写:任意UTF8字符的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道我可以使用什么符号来指代utf8编码表中的任何字符来进行nginx重写.我已经尝试过:
I want to know what symbol I can use to refer to any character within the utf8 encoding table for nginx rewriting. I have tried:
rewrite ^/.$ /new-location.html break;但似乎是."只能代表ASCII字符,当我尝试 example /汉(中文字符)时,确实不行.
but it seems the "." can only stand for ascii characters, when I tried example/汉 (a Chinese character), it did not work.
这也不起作用:
rewrite ^/([\x00-\xff])$ /new-location.html break;推荐答案
来自文档:
但是,必须支持UTF-8和Unicode 明确启用;它不是默认值. Unicode表对应于 转换为Unicode版本6.0.0.
However, UTF-8 and Unicode support has to be explicitly enabled; it is not the default. The Unicode tables corre- spond to Unicode release 6.0.0.
所以您必须启用utf-8才能工作:
So you have to enable utf-8 to work :
"(*UTF8)^yourregex$"更多推荐
nginx重写:任意UTF8字符的符号
发布评论