【发布时间】:2017-06-27 07:15:26
【问题描述】:
我在 CodeIgniter 中开发了两个应用程序,它们都在单独的服务器上工作,即
www.CI_App_1.com
和
www.CI_App_2.com
现在我想将CI_App_2 集成到CI_App_1 应用程序中,所以之后我可以从CI_App_1 的链接之一调用default_controller 的CI_App_2。
我的文件夹结构:
htdocs :
-application_1
-application
-application_2
-application
-config
-autoload.php
-config.php
-routes.php
-controllers
-app_2_controller.php
-helpers
-libraries
-models
-app_2_model.php
-views
-app_2_view.php
-system
-.htaccess
-index.php
-config
-autoload.php
-config.php
-routes.php
-controllers
-app_1_controller.php
-helpers
-libraries
-models
-app_1_model.php
-views
-app_1_view.php
-system
-.htaccess
-index.php
我想在用户从CI_App_1 登录后访问 CI_App_2。验证过程后,用户只能访问我的CI_App_2,如果用户尝试在没有验证的情况下访问它,则会收到错误消息:
禁止访问
我参考了以下链接:
Call Controller method of CodeIgniter outside Application directory
CodeIgniter: Load controller within controller
How to load a controller from another controller in codeigniter?
Codeigniter : calling a method of one controller from other
http://www.techsirius.com/2013/01/load-controller-within-another.html
http://www.devnetwork.net/viewtopic.php?f=72&t=131353
how to set up two codeigniter applications running on same server
https://www.codeigniter.com/user_guide/general/managing_apps.html
但在上面的链接中,他们说应该使用 HMVC 模块结构来完成,但没有人提到两个控制器文件来自相同的应用程序或不同的应用程序。我想从第二个应用程序访问default_controller 到第一个应用程序。
有可能吗?
感谢任何形式的帮助。提前致谢。希望你能得到我的问题。
【问题讨论】:
-
我认为最好的办法是稍微重组一下,让 app_1 和 app_2 处于同一级别(不嵌套),并为两者创建一个新的身份验证方法
-
请举例说明你想说什么。因为我试图将 App2 中的 default_controller 添加到 App1 的 Controller 文件夹中。并为他们重写路线。但它没有用。
-
听起来您想要跨服务器进行身份验证。 See this answer about a custom session handler.
标签: php .htaccess codeigniter url-routing