【发布时间】:2015-11-25 00:44:33
【问题描述】:
在 CodeIgniter 中,我的 url someurl.com/test/ 不会在控制器类中执行任何操作。请看一下并告诉我是否有您能想到的可能会阻止执行 CI_Controller 在这里或我应该看的地方。
例如下面的
some.testurl.com/test/hi/Bob
some.testurl.com/test
some.testurl.com/test/hi
全部显示:
Above class
Below class
编辑:
我相信我的问题在于我如何尝试运行两个单独的应用程序。一个位于testurl.com,另一个位于some.testurl.com,其中some.testurl.com 的目录是testurl.com 所在目录的子文件夹。它们都起作用的正确方法是什么?
更新: 将子域移到其他 CodeIgniter 应用程序的目录之外并没有以任何方式改变行为。 CodeIgniter 控制器不做任何事情。
这是我的代码:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
echo "Above class<br>";
class Test extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('mod_login');
$this->load->helper('date');
}
//443 replace with 482
function index() {
echo "Index function";
}
function hi($name)
{
echo "Hi".$name."!";
}
}
echo "Below class<br>";
?>
这是我的 .htaccess 文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|common|ico|database_backup|images|img|js|scripts|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
- 已启用错误报告,并且未触发任何错误。环境定义为索引文件上的开发。
【问题讨论】:
-
你的控制器文件很好。我猜你可能在帮助文件或模型文件上有错误。也检查这些文件。您可以启用错误报告并检查错误。
-
这是否工作 someurl.com/index.php/test/ ?
-
你好,修正者。当我尝试得到 CI 生成的 404 错误时。
标签: php codeigniter codeigniter-2 codeigniter-routing