2016-07-08 174 views
1

这里是主控制器(欢迎):笨链接无法正常工作

<?php 
defined('BASEPATH') OR exit('No direct script access allowed'); 

class Welcome extends CI_Controller { 


    public function index() 
    { 
     $this->login(); 
    } 


    public function login() 
    { 
     $this->load->view("index"); 
    } 

    public function home() 
    { 
     $this->load->view("home"); 
    } 

索引页工作正常这是一个登录页面,但每当我登录按钮点击(这是应该带我的主页),它加载主页,但没有造型,虽然造型是在同一个页面home.php和功能的家用正常工作,因为我改变了

public function index() 
    { 
     $this->login(); 
    } 

到:

public function index() 
    { 
     $this->home(); 
    } 

只是为了测试它,并链接到它时,它不会加载它造型精美的作品与所有的造型,还是,,这里的登录按钮代码:

<a href="<?php echo base_url(); ?>index.php/welcome/home" 
    class="btn btn-greensea b-0 br-2 mr-5" > Login</a> 

任何人都可以帮忙吗? 感谢

回答

0

第一件事:

确保阿帕奇对rewrite_mode和.htaccess文件是在正确的位置。

在config.php文件:

$config['base_url'] = 'http://localhost/yourappfoldername/'; 

//按照文档,总是设置基本URL以斜线

在控制器:

public function __construct() 
{ 
parent::__construct(); 
$this->load->helper(array('url')); 

//======== or simply =============== 

$this->load->helper('url'); 

}