nginx重写:任意UTF8字符的符号 [英] nginx rewrite: the symbol for ANY UTF8 character

查看:153
本文介绍了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字符,当我尝试 http://example.com /汉(中文字符)时,确实不行.

but it seems the "." can only stand for ascii characters, when I tried http://example.com/汉 (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字符的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆