Home  >  Article  >  Backend Development  >  正则匹配中文问题

正则匹配中文问题

WBOY
WBOYOriginal
2016-06-23 14:15:09954browse

RewriteRule ^test/(\w+)$ test/test.php?t=$1

url:test/abcd   可以跳转
url:test/好     不可以跳转

怎么办?
另外让abcd.sdfsdf
里面带.的也不跳转


回复讨论(解决方案)

apache 不支持中文路径
不安装插件是无法解决的

RewriteRule ^test/([\w\x{4e00}-\x{9fa5}]+)$ test/test.php?t=$1

这样试试

RewriteRule ^test/([\w\x{4e00}-\x{9fa5}]+)$ test/test.php?t=$1

这样试试
谢谢
你这语句需加三个\\\,不然直接跳到404
([\w\\x{4e00}\-\\x{9fa5}]+)
但是中文还不行,我又试了下发现(.*)可以正确跳到页面了,但是别的地方都跳了(.*)范围太大了
怎么排除掉点".",如果能用上(.*)说不定能成
(.*)[?!\.] 这样不对劲(就是参数里不能有点.)
(我只是js传个中文参数的目的)

([^\.]+)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn