在相同的CodeIgniter 2.x应用程序上使用多个数据库并使用URI路由发出问题

在相同的CodeIgniter 2.x应用程序上使用多个数据库并使用URI路由发出问题

问题描述:

I am working on a small web application. In my application I follow the following approach.

Small overview of system

  1. The Application will be hosted on the server for example (www.example.com )
  2. Clients such as Microsoft, Cocacola, IBM.... etc will sign up. And the clients will access the application by using url like this ( www.example.com/ibm )
  3. Each client will have separate database to store their data.
  4. If the employees of the client want to login into the system then the url pattern should be like this :

    (www.example.com/ibm/user/login)
    ibm - is the client
    user - is controller
    login - is method of user controller

How to achieve this?

我正在开发一个小型Web应用程序。 在我的应用程序中,我遵循以下方法。 p>

系统的小概述 p>

  1. 应用程序将托管在服务器上,例如 (www.example.com) li>
  2. 微软,Cocacola,IBM等客户将注册。 客户将使用这样的URL访问应用程序(www.example.com/ibm) li>
  3. 每个客户端都有单独的数据库来存储他们的数据。 li>
  4. 如果客户的员工想要登录系统,则网址格式应如下所示: p>

    (www.example.com/ibm/user/login)
    ibm - 是客户端
    user - 是控制器
    login - 是用户控制器的方法 p> li> ol>

    如何实现 这个? p> div>

Thanks Sundar for your advice. We can achieve this just by little hack in core of codeigniter.

  1. Open system/core/router.php in your text editor.
  2. Go to Line number 264 .... function _validate_request($segments)
  3. Replace $segments[0] with $segments[1] OR
  4. Add this code at line 270

    $x=$segments; $a=1; for($i=0;$i<(count($segments)-1); $i++) { $segments[$i]=$x[$a]; $a++; }