默认情况下,codeigniter网址是否100%支持非英文字符?

时间:2012-02-20 21:27:59

标签: codeigniter url-rewriting urlencode codeigniter-url non-english

我想确定CodeIgniter是否100%支持此行为。

令我怀疑的是config.php permitted_uri_chars如下:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

它表示允许仅限英语字符。但请考虑以下网址的结果:

  • http://localhost/codeigniter/index.php/controller/method/hell0-there+++

结果:The URI you submitted has disallowed characters.

  • http://localhost/codeigniter/index.php/controller/method/hello-سلام

结果:没问题!!!

سلام模式不能接受单词'a-z 0-9~%.:_\-'(用波斯语表示“hello”),但它不像前面的例子那样错误!

为什么会出现这种情况?

现在接下来的问题:是否有任何需要添加并在模式中包含波斯字符?

我在考虑将config.php更改为:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

// Add all the persian characters after standard pattern:
$config['permitted_uri_chars'] .= 'آابپتثجچحخدذرزسشصضطظعغفقکگلمنوهیي‌۱۲۳۴۵۶۷۸۹۰';

3 个答案:

答案 0 :(得分:2)

非ASCII字符应该是URLEncoded,将它们转换为%F3等。根据%a-z 0-9

我认为这是允许的

答案 1 :(得分:1)

以这种方式使用它,更改配置文件:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-|آ-ی';

这样它支持除“Hamze”之外的所有字符。如果你想支持“Hamze”,你可以用这种方式改变它:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-|آ-یء';

答案 2 :(得分:0)

我刚刚读了你的问题,它有一个简单的答案,我已达到!答案是:

$route[urlencode ('ورود-به-حساب-کاربری')] = 'Login';

您不需要按照您的说法操作配置文件!因此,您只需将此行代码设置为route.php。 它对我有用。