我有两个不同的模块,一个是 codeigniter 模块,另一个是 laravel5 模块。
我的问题
Is it possible to set a common routing between these two module ?
我正在使用 CI v2.2.6
和 Laravel 5.0
我已经尝试使用 .htaccess
但我无法执行我想要的操作。
我在 CI
模块 Ex 中有一些页面:
/home
/login
/signup
/otherPages
我在 laravel
中有一些页面 Ex:
/product
/buy
/edit
/otherPages
现在我要访问
mywebsite.com/home
mywebsite.com/product
and all
我该怎么做?
最佳答案
.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);
关于php - 如何在 CI 和 Laravel 之间设置路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35081853/