.htaccess rewrite rule won't unicode character

2020-03-27 08:00发布

I am using the following ModRewrite to make my urls look cleaner:

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

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.

1条回答
Anthone
2楼-- · 2020-03-27 08:25

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]

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!

查看更多
登录 后发表回答