简体   繁体   English

Codeigniter路由后端和前端的配置

[英]codeigniter routes config for backend and frontend

I want to have this site structure> 我想要这个网站结构>

site>application>controllers
  >backend
    Admin.php
  >frontend
    Main.php

So when I enter to my site it should be> 因此,当我进入自己的网站时,应该是>

So far I could not make it. 到目前为止,我还没做到。 I could only make work the frontend main page with this structure> 我只能使用这种结构使前端主页工作>

site>application>controllers
  >backend
  >frontend
  Main.php (outside frontend folder)

and in routes.php: 并在route.php中:

  $route['default_controller'] = 'main/index';

how can I configure codeigniter so I can have what I need? 如何配置codeigniter,以便可以满足需要?

Use this 用这个

$config['admin'] = 'backend/Admin'; #http://example.com/admin
$route['some_name'] = 'frontend/some_name'; #http://example.com/some_name
$route['default_controller'] = 'main'; #http://example.com/

In 'default_controller' you no need to define index it will call automatically. 'default_controller'您无需定义将自动调用的index

Try this: 尝试这个:

$config['backend/Admin'] = 'admin';               // http://example.com/admin
$config['default_controller'] = 'frontend/Main';  //http://example.com/

Try this: In router.php 试试这个:在router.php中

$route['default_controller'] = 'frontend/main/index';
$route['admin/(:any)'] = "backend/$1";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM