我是CodeIgniter的新手并试图在Homepage上创建一个简单的链接,但它在WAMP Server上重定向到localhost,这是我的代码
配置文件夹中的autoload.php
$autoload['helper'] = array('html', 'url');
配置文件夹中的config.php
$config['base_url'] = 'http://localhost:8080/OTI-CI';
配置文件夹中的routes.php
$route['default_controller'] = 'site';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
这是我的控制器: site.php
class Site extends CI_Controller {
public function index() {
$this->home();
}
public function home() {
$this->load->view("header");
$this->load->view("content_home");
$this->load->view("footer");
}
}
这是我的 .htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /OTI-CI/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
这里是我的标题视图,包括像
这样的链接<a href="<?php echo base_url(); ?>site/home">Home</a>
有什么我想念的吗?
答案 0 :(得分:0)
在CodeIgniter 3.x
版本中,您应该将控制器,库和模型名称大写。就像Site.php
/application/controllers/site.php
/application/controllers/Site.php