CodeIgniter URI 中不允许使用句点? [英] Periods not allowed in CodeIgniter URI?
问题描述
因此,在阅读了关于 API 版本控制的这个问题后,我决定将所有带有版本号的路由:
So after reading this question on API versioning, I decided to prefix all my routes with a version number:
http://localhost/api/1.0/user/login
但是当我在 Exceptions Core 中抛出异常时,它说路由是:
But when I throw an exception within Exceptions Core, it says that the route is:
10/UserControll...
我试过逃避这段时间,但这没有用.任何人都可以复制这个问题并想出可能的解决方案吗?
I've tried escaping the period, but this did not work. Can anyone replicate this problem and think of a possible solution for it?
这是我用于上述的路线:
This is the route I am using for the above:
$route['1.0/user/(:any)'] = '1.0/UserController/$1';
这些是我允许的 URI 字符:
These are my permitted URI chars:
$config['permitted_uri_chars'] = 'a-z 0-9~%\.:_\-';
推荐答案
问题出在system/core/Router.php
的468行.从这里更改 set_directory
:
The problem is on line 468 of system/core/Router.php
. Change set_directory
from this:
$this->directory = str_replace(array('/', '.'), '', $dir).'/';
为此:
$this->directory = str_replace(array('/'), '', $dir).'/';
有没有人猜测或猜想路由器为什么从目录名称中删除句点?
Anyone have a guess or gander as to why the Router removes periods from directory names?
这篇关于CodeIgniter URI 中不允许使用句点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!