nginx重写:任意UTF8字符的符号

编程入门 行业动态 更新时间:2024-10-26 08:31:07
本文介绍了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字符的符号

本文发布于:2023-10-28 05:30:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535668.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   符号   字符   nginx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!