我刚开始学习codeigniter,我注意到了。写完这样的路线之后
$route['index'] = "front/index";
$route['page/(:any)'] = "front/page/$1";
$route['section/(:any)'] = "front/section/$1";
现在我可以使用旧路线和新路线访问方法和控制器。
现在可以使用URL:
localhost/index
localhost/front/index
localhost/front/index.html
指向同一位置的网址太多,我想知道每种方法是否只能有1个网址,而不使用外部代码限制所有其他网址。从代码点火器本身。
另外:这会破坏我使用uri类从网址获取细分的能力。
答案 0 :(得分:0)
最简单的方法是将您的索引页面作为默认控制器的唯一(索引)功能,在您的情况下只是
$route['default_controller'] = "front";
然后所有其他页面都有其他控制器及其相应的URI名称,那么除了默认值之外你不需要任何路由。我通常最终会得到一些控制器,例如page.php
,news.php
,blog.php
,products.php
,admin.php
等等。