【问题标题】:How to set routing between CI and Laravel如何在 CI 和 Laravel 之间设置路由
【发布时间】:2016-05-07 00:44:18
【问题描述】:

我有两个不同的模块,一个是 codeigniter 模块,第二个是 laravel5 模块。

我的问题

是否可以在这两个模块之间设置一个公共路由?

我正在使用 CI v2.2.6Laravel 5.0 我已尝试使用 .htaccess 但我无法执行我想要的操作。

我在CI 模块中有一些页面,例如:

/home
/login
/signup
/otherPages

我在laravel 有一些页面,例如:

/product
/buy
/edit
/otherPages 

现在我想访问

 mywebsite.com/home
 mywebsite.com/product
 and all

我该怎么做?

【问题讨论】:

    标签: php codeigniter laravel routing


    【解决方案1】:

    .htaccess

    <IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . control.php [L]
    </IfModule>
    

    创建文件 control.php

     #split the path by '/'
      $params     = split("/", $_SERVER['REQUEST_URI']);
        define("FILE_PHP",".php");
        define("ERROR_404","404.php");
        define("INCLUDE_ADMIN","index.php");
        class Loader{
    
         public function __autoload($params) {
             if(isset($params[1])==TRUE){ 
              if (file_exists($params[1].FILE_PHP)) { 
                  require_once $params[1].FILE_PHP; 
                  return true; 
              } 
               require_once ERROR_404; 
              return false; 
             }else{
              require_once INCLUDE_ADMIN; 
              return TRUE; 
             }
        } 
        }
        $loader=new Loader();
        $loader->__autoload ($params);
    

    【讨论】:

      猜你喜欢
      • 2016-04-25
      • 2017-05-19
      • 2022-11-26
      • 2019-04-24
      • 1970-01-01
      • 2021-10-07
      • 1970-01-01
      • 2019-05-20
      • 2019-01-13
      相关资源
      最近更新 更多