douliao8318 2015-09-20 14:29
浏览 11
已采纳

Codeigniter:创建索引页面

My folder structure is as following

admin
__master
_______address_book
_______Users
_______Product
_______etc
__operations
_______register_orders
_______payments
_______etc

I have created controllers for address_book,users,products,register_orders, payments etc to reduce the complexity of each controller.

Now, how to handle index page request for www.abc.com/admin ? I have created Admin controller in /controllers directory then other links like www.abc.com/admin/master/address_book will not work.

How to handle both requests? I would also like to know is there any way to handle each index page requests eg:

www.abc.com/admin/
www.abc.com/admin/master/
www.abc.com/admin/operations/
  • 写回答

2条回答 默认 最新

  • doude5860 2015-09-20 14:58
    关注

    To access each request with url like-

    www.abc.com/admin/
    www.abc.com/admin/master/
    www.abc.com/admin/operations/
    

    you have to use codeigniter's routing. And for routing there are a config file under aplication/config folder named routes.php. Add all your routes in this file. Suppose you want to access this url-

    www.abc.com/admin/operations/
    

    then you have to create a new route for this in the route file, like-

    $route['admin/operations']  = 'admin/operations';
    

    where in $route array index you have to mention what will be the url and the value against this index you have to mention the controller's path and also you can mention the controller's function name which will be invoked (for index function there no need for mentioning).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥15 看一下OPENMV原理图有没有错误
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解
  • ¥15 有偿请教计算电磁学的问题涉及到空间中时域UTD和FDTD算法结合的
  • ¥15 vite打包后,页面出现h.createElement is not a function,但本地运行正常
  • ¥15 Java,消息推送配置
  • ¥15 Java计划序号重编制功能,此功能会对所有序号重新排序,排序后不改变前后置关系。
  • ¥15 关于哈夫曼树应用得到一些问题