【发布时间】:2015-05-11 15:54:39
【问题描述】:
我正在使用 CodeIgniter 的 routes 文件将短网址重新映射到其相关的控制器功能。
奇怪的是,一些 url 被重新映射,而另一些则没有,即使语法相同。
下面是我的routes.php 文件。 info/web 和 info/rent 的重新映射按预期工作,而 info/cell 和 info/hotel 被重定向到我的 404 函数。
知道是什么原因造成的吗?
$route['default_controller'] = "home";
$route['404_override'] = 'home/four_o_four';
$route['robots.txt'] = 'home/robots';
$route['info/cell'] = "articles/tags/cellphone";
$route['info/rent'] = "articles/tags/car-rental";
$route['info/web'] = "articles/tags/internet-abroad";
$route['info/hotel'] = "articles/tags/hotel";
$route['articles/tags/(:any)'] = "articles/articles_by_tags/$1";
$route['articles/destination/(:any)'] = "articles/articles_by_destination/$1";
$route['articles/(:any)'] = "articles/show_article/$1";
【问题讨论】:
-
顺序很重要。如果不正确,较高的路线将覆盖下面的路线。
-
我认为控制器中的问题不在路由表中。
标签: codeigniter routes