我已将我的codeigniter安装在子域http://mt.domain.com上,并设置了$ config ['base_url'] ='http://mt.domain.com'。
我有用户面板和管理面板,这是已经安装的用户面板控制器: application / controllers / User.php ,此用户面板可以100%工作。
但是管理面板和登录面板存在错误,它们已经放在子文件夹中: application / controllers / staff / Login.php
截图: error login
因此,当我将控制器放在子文件夹上时,发生了问题,例如: mt.domain.com/subfolder/admin
如何解决这个问题?谢谢
这是我的控制器Login.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login extends CI_Controller{
function __construct(){
parent:: __construct();
$this->load->model('m_admin');
$this->load->helper('captcha');
$this->load->library('encryption');
}
function index(){
$this->load->view('admin/login/v_login');
}
这是我在views / admin / login / v_login.php上的视图文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Login - Bootstrap Admin Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="<?php echo base_url('assets/admin/css/bootstrap.min.css');?>" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url('assets/admin/css/bootstrap-responsive.min.css');?>" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url('assets/admin/css/font-awesome.css');?>" rel="stylesheet">
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600" rel="stylesheet">
<link href="<?php echo base_url('assets/admin/css/style.css" rel="stylesheet');?>" type="text/css">
<link href="<?php echo base_url('assets/admin/css/pages/signin.css');?>" rel="stylesheet" type="text/css">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" >
Login Admin MBill V.1.0
</a>
<div class="nav-collapse">
<ul class="nav pull-right">
<li class="">
<a href="https://mt.adrihost.com/" class="">
<i class="icon-chevron-left"></i>
Back to Homepage
</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div> <!-- /container -->
</div> <!-- /navbar-inner -->
</div> <!-- /navbar -->
<div class="account-container">
<div class="content clearfix">
<form action="<?php echo base_url('staff/login/aksi_login');?>" method="post">
<h1>Admin Login</h1>
<div class="login-fields">
<p>Please provide your details</p>
<div class="field">
<label for="username">Username</label>
<input type="text" id="username" name="username" value="" placeholder="Username" class="login username-field" />
</div> <!-- /field -->
<div class="field">
<label for="password">Password:</label>
<input type="password" id="password" name="password" value="" placeholder="Password" class="login password-field"/>
</div> <!-- /password -->
</div> <!-- /login-fields -->
<div class="login-actions">
<span class="login-checkbox">
<input id="Field" name="Field" type="checkbox" class="field login-checkbox" value="First Choice" tabindex="4" />
<label class="choice" for="Field">Keep me signed in</label>
</span>
<input type="submit" class="button btn btn-success btn-large" value="Sign In">
</div> <!-- .actions -->
</form>
</div> <!-- /content -->
</div> <!-- /account-container -->
<div class="login-extra">
<a href="#">Reset Password</a>
</div> <!-- /login-extra -->
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/signin.js"></script>
</body>
</html>
答案 0 :(得分:1)
您应该使用/在所有资产中找到基本目录
将'assets'/ ...替换为'/ assets / ...'
例子
旧的:
<link href="<?php echo base_url('assets/admin/css/bootstrap.min.css');?>" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url('/assets/admin/css/bootstrap.min.css');?>" rel="stylesheet" type="text/css" />
答案 1 :(得分:0)
问题解决了。
问题出在css文件上,需要在root上正确安装资产文件夹。所以我决定将所有css文件放在根目录下。然后问题解决了。
非常感谢。