Codeigniter:所有阿拉伯路线均无效 [英] Codeigniter: All Arabic routes are not working

查看:83
本文介绍了Codeigniter:所有阿拉伯路线均无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[更新]

已添加到配置中但仍无法正常工作

Added to the config but still not working

$config['permitted_uri_chars'] .= '%D8%A2%D8%A7%D8%A8%D9%BE%D8%AA%D8%AB%D8%AC%DA%86%D8%AD%D8%AE%D8%AF%D8%B0%D8%B1%D8%B2%D8%B3%D8%B4%D8%B5%D8%B6%D8%B7%D8%B8%D8%B9%D8%BA%D9%81%D9%82%DA%A9%DA%AF%D9%84%D9%85%D9%86%D9%88%D9%87%DB%8C%D9%8A%DB%B1%DB%B2%DB%B3%DB%B4%DB%B5%DB%B6%DB%B7%DB%B8%DB%B9%DB%B0';

$config['charset'] = 'UTF-8'; //by default

我已将Codeigniter从2.1更新为2.2,然后更新为3。在使用阿拉伯字符的路由中,我重定向到找不到对象页面

I have updated Codeigniter from 2.1 to 2.2 then to 3. The issue I have is in the routes in Arabic characters I get redirected to "Object not found" page

$route['cat/(:any)/(:any)'] = 'cat/index/$1/$2';
$route['tour/(:any)/(:any)'] = 'tour/index/$1/$2';
$route['sub_category/(:any)/(:any)'] = 'sub_category/index/$1/$2';
$route['default_controller'] = "home";
$route['404_override'] = '';
$route['order'] = 'order/index/';
$route[urlencode('البومات-الصور')] = 'gallery/index/$1'; //the Arabic one which is not working

当我回声urlencode('البومات-الصور') ;我得到了

And when I echo urlencode('البومات-الصور'); I get

%D8%A7%D9%84%D8%A8%D9%88%D9%85%D8%A7%D8%AA-%D8%A7%D9%84%D8%B5%D9%88%D8%B1 

如果我将urlencode('البومات-الصور')更改为$ route ['albums']之类的英语内容,效果很好。

If I change urlencode('البومات-الصور') to anything in English like $route['albums'] it works fine.

我使用了相同的方法路由而没有编码,并且出现相同的错误找不到对象!在此服务器上找不到请求的URL。

I used the same route without encoding and I get the same error "object not found! The requested URL was not found on this server."

如何解决此问题?

推荐答案

在进行了所有澄清之后,归结为您的服务器如何处理字符编码。

After all that clarification, it came down to how your server was handling character encoding.

这里是链接。它有许多以不同方式处理它的答案。这是一个对htaccess文件执行重写规则的程序。

Here's a link from another Stack Overflow question that is similar. It has many answers that deal with it in different ways. Here's one that does a rewrite rule for the htaccess file.

RewriteRule ^([\s\S]*)$ index.php?rt=$1 [L,B,QSA]

这篇关于Codeigniter:所有阿拉伯路线均无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆