Codeigniter:所有阿拉伯路线都不起作用 [英] Codeigniter: All Arabic routes are not working

查看:15
本文介绍了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.

这是一个链接 来自另一个类似的 Stack Overflow 问题.它有许多以不同方式处理它的答案.这是对 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 ^([sS]*)$ index.php?rt=$1 [L,B,QSA]

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

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