本文介绍了htaccess的重写规则不会UNI code字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的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错误,当我尝试使用%,我需要使用UNI code字符#/',等等。这背后的任何原因?谢谢你。

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 标记中的重写规则。看看阿帕奇手动

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的使用转义字符,所以如果你想使用UNI code字符,请使用它们重写规则,并保存的.htaccess 文件中UNI code!

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的重写规则不会UNI code字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 14:06
查看更多