Codeigniter: All Arabic routes are not working

元气小坏坏 提交于 2019-12-13 17:22:54

问题


[Update]

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

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

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 

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

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."

How to solve this issue?


回答1:


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

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]


来源:https://stackoverflow.com/questions/56229130/codeigniter-all-arabic-routes-are-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!