我对 CodeIgniter 非常陌生,并且无法从我的默认类中调用函数。
控制器
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends CI_Controller
{
public function index()
{
$this->welcome();
}
public function welcome()
{
$this->load->view('view_welcome');
}
}
.htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /pickme/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
目前它默认调用这个主控制器,正如我所期望的那样。
例如
localhost/sitename
AND
localhost/sitename/index.php
AND
localhost/sitename/index.php/main/index
(All have the same result)
所以我的印象是
localhost/sitename/class/function/id
将是 htaccess 的工作方式,但是当我尝试访问时出现 404 错误
localhost/sitename/main/welcome