Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
默认情况下,codeigniter URL是否100%支持非英语字符?_Codeigniter_Url Rewriting_Urlencode_Codeigniter Url_Non English - Fatal编程技术网

默认情况下,codeigniter URL是否100%支持非英语字符?

默认情况下,codeigniter URL是否100%支持非英语字符?,codeigniter,url-rewriting,urlencode,codeigniter-url,non-english,Codeigniter,Url Rewriting,Urlencode,Codeigniter Url,Non English,我想确定CodeIgniter是否100%支持这种行为 让我怀疑的是,在config.php中,允许的uri\u字符如下所示: $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; 上面说只允许使用英语字符。但是考虑以下URL的结果: http://localhost/codeigniter/index.php/controller/method/hell0-there+++ 结果:您提交的URI包含不允许的字符。 http://local

我想确定CodeIgniter是否100%支持这种行为

让我怀疑的是,在
config.php
中,
允许的uri\u字符
如下所示:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
上面说只允许使用英语字符。但是考虑以下URL的结果:

  • http://localhost/codeigniter/index.php/controller/method/hell0-there+++
结果:
您提交的URI包含不允许的字符。

  • http://localhost/codeigniter/index.php/controller/method/hello-سلام
结果:没问题

模式
'a-z 0-9~%不能接受单词
(波斯语,意思是“hello”):\u \-'
,但它不会像前面的示例那样出错

为什么会发生这种行为?

现在是下一个问题:是否需要在模式中添加并包含波斯语字符?

我想把
config.php
改成这样:

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

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

非ASCII字符应为URLEncoded,将其转换为
%F3
等。我认为基于
%
a-z 0-9
非ASCII字符应为URLEncoded,将其转换为
%F3
等,我认为基于
%
a-z>是允许的0-9

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

$config['allowed_uri_chars']='a-z 0-9~%:\-Әآ-ی 

这样,它支持除“Hamze”之外的所有字符。如果您想支持“Hamze”,可以通过以下方式进行更改:

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

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

$config['allowed_uri_chars']='a-z 0-9~%:\-Әآ-ی 

这样,它支持除“Hamze”之外的所有字符。如果您想支持“Hamze”,可以通过以下方式进行更改:

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

我刚刚读了你的问题,我得到了一个简单的答案!答案是:

$route[urlencode ('ورود-به-حساب-کاربری')] = 'Login';
你不需要像你说的那样操纵你的配置文件!因此,您也只需要将这行代码设置到
route.php
中。
这对我很有用。

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

$route[urlencode ('ورود-به-حساب-کاربری')] = 'Login';
你不需要像你说的那样操纵你的配置文件!因此,您也只需要将这行代码设置到
route.php
中。
这对我很有用。

+1完美而结论性的答案!我从未想过这样的解决方案(基于转换和关联
urlencode()
)。非常感谢:)我也会更新搜索引擎优化标签。亲爱的朋友,你应该再等一分钟!这也是我应该做的;)+一个完美的结论性答案!我从未想过这样的解决方案(基于转换和关联
urlencode()
)。非常感谢:)我也会更新搜索引擎优化标签。亲爱的朋友,你应该再等一分钟!这也是我应该做的;)这是更好的答案,因为我希望在url中保持其他语言文本可见,但希望通过$config['allowed_uri_chars']='a-z 0-9~%中的uri限制:;我不认为会有任何安全问题,因为只会传递路由中指定的单词。我很高兴听到这对您很有用。这是更好的答案,因为我希望在url中保持其他语言文本可见,但希望通过$config['allowed_uri_chars']='a-z 0-9~%中的uri限制:;我不认为有任何安全问题,因为只会传递路由中指定的单词。我很高兴听到它对您有用。