.htaccess 重写规则不会对字符进行 unicode [英] .htaccess rewrite rule won't unicode characters
问题描述
我正在使用以下 ModRewrite 使我的网址看起来更干净:
I am using the following ModRewrite to make my urls look cleaner:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?key=$1
它允许使用字母和数字就好了,但是当我尝试使用 % 时会产生 400 错误,我需要将 unicode 字符用于 #/' 等.这背后有什么原因吗?谢谢.
It allows use of letters and numbers just fine, but it produces a 400 error when i try to use %, which I require to use unicode characters for # / ', etc. Any reason behind this? Thanks.
推荐答案
你应该在你的重写规则中使用 B
标志.看看apache手册.
>
you should use B
flag in your rewrite rule. take a look at apache manual .
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-#$%^&]+)/?$ index.php?key=$1 [B]
编辑:mod_rewrite 使用非转义字符,所以如果你想使用unicode 字符,在重写规则中使用它们并将.htaccess
文件保存在unicode 中!
Edit:
mod_rewrite uses unescaped characters, so if you want to use unicode characters, use them in rewrite rule and save .htaccess
file in unicode!
这篇关于.htaccess 重写规则不会对字符进行 unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!