.htaccess重写规则不会unicode字符

我正在使用下面的ModRewrite,使我的网站看起来更干净:

RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?key=$1 

它允许使用字母和数字就好了,但是当我尝试使用%时,它会产生400错误,我需要使用unicode字符作为#/',等等。 谢谢。

你应该在你的重写规则中使用B标志。 看看Apache手册 。

 RewriteEngine On RewriteRule ^([a-zA-Z0-9_-#$%^&]+)/?$ index.php?key=$1 [B] 

编辑 :mod_rewrite使用非转义字符,所以如果你想使用unicode字符,使用它们在重写规则和保存.htaccess文件在Unicode!