我的主页看起来像
应用程序文件夹中的config.php。
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['base_url'] = 'http://localhost/antimalarial/';
$config['index_page'] = "index.php?";
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'MY_';
$config['composer_autoload'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['log_threshold'] = 0;
$config['log_path'] = '';
$config['log_file_extension'] = '';
$config['log_file_permissions'] = 0644;
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['error_views_path'] = '';
$config['cache_path'] = '';
$config['cache_query_string'] = FALSE;
$config['encryption_key'] = '';
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
$config['standardize_newlines'] = FALSE;
$config['global_xss_filtering'] = FALSE;
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';
&#13;
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'Welcome';
$route['(:any)'] = 'Welcome/$1';
&#13;
Controller文件夹中的Welcome.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function __construct() {
parent::__construct();
}
public function index()
{
$this->load->view('header.php');
$this->load->view('home.php');
$this->load->view('footer.php');
}
public function home()
{
$this->load->view('header.php');
$this->load->view('home.php');
$this->load->view('footer.php');
}
public function fivespecies()
{
$this->load->view('header.php');
$this->load->view('fivespecies.php');
$this->load->view('footer.php');
}
public function parasite()
{
$this->load->view('header.php');
$this->load->view('parasite.php');
$this->load->view('footer.php');
}
public function definite()
{
$this->load->view('header.php');
$this->load->view('definite.php');
$this->load->view('footer.php');
}
public function currenttools()
{
$this->load->view('header.php');
$this->load->view('currenttools.php');
$this->load->view('footer.php');
}
public function malariatreatment()
{
$this->load->view('header.php');
$this->load->view('malariatreatment.php');
$this->load->view('footer.php');
}
public function history()
{
$this->load->view('header.php');
$this->load->view('history.php');
$this->load->view('footer.php');
}
public function Areasofwork()
{
$this->load->view('header.php');
$this->load->view('Areasofwork.php');
$this->load->view('footer.php');
}
public function mapofprojects()
{
$this->load->view('header.php');
$this->load->view('mapofprojects.php');
$this->load->view('footer.php');
}
public function toolkits()
{
$this->load->view('header.php');
$this->load->view('toolkits.php');
$this->load->view('footer.php');
}
public function globalmalariamapper()
{
$this->load->view('header.php');
$this->load->view('globalmalariamapper.php');
$this->load->view('footer.php');
}
public function aboutus()
{
$this->load->view('header.php');
$this->load->view('aboutus.php');
$this->load->view('footer.php');
}
public function faq()
{
$this->load->view('header.php');
$this->load->view('faq.php');
$this->load->view('footer.php');
}
public function privacy()
{
$this->load->view('header.php');
$this->load->view('privacy.php');
$this->load->view('footer.php');
}
public function feedback() {
if (isset($_POST ['feedsubmit'])) {
$in_name = $this->input->post('name');
$in_email = $this->input->post('email');
$in_college = $this->input->post('college');
$in_phone = $this->input->post('phone');
$in_message = $this->input->post('message');
$result = $this->USER_MODEL->add_new_feedback($in_name, $in_email, $in_college, $in_phone, $in_message);
if ($result) {
echo "<script>alert('Feed Submitted Succesfully');</script>";
unset($_POST);
$this->feedback();
//redirect(base_url() . "feedback");
} else {
echo "<script>alert('Feed Already Submitted');</script>";
unset($_POST);
$this->feedback();
//redirect(base_url() . "feedback");
}
} else {
$this->load->view('header');
$this->load->view('feedback');
$this->load->view('footer');
}
}
}
&#13;
view.php在视图文件夹中。
<!-- === BEGIN HEADER === -->
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<head>
<!-- Title -->
<title>Database for antimalarial Drug</title>
<!-- Meta -->
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<!-- Favicon -->
<link href="favicon.ico" rel="shortcut icon">
<!-- Bootstrap Core CSS -->
<link rel="stylesheet" href="assets/css/bootstrap.css" rel="stylesheet">
<!-- Template CSS -->
<link rel="stylesheet" href="assets/css/animate.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/nexus.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/responsive.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css" rel="stylesheet">
<!-- Google Fonts-->
<link href="http://fonts.googleapis.com/css?family=Roboto+Condensed:400,300" rel="stylesheet" type="text/css">
</head>
<body>
<div id="body-bg">
<!-- Phone/Email -->
<div id="pre-header" class="background-gray-lighter">
<div class="container no-padding">
<div class="row hidden-xs">
<!--<div class="col-sm-6 padding-vert-5">
<strong>Phone:</strong> 9030051219
</div>-->
</div>
</div>
</div>
<!-- End Phone/Email -->
<!-- Header -->
<div id="header">
<div class="container">
<div class="row">
<!-- Logo -->
<div class="logo">
<a href="index.html" title="">
<img src="assets/img/logo1.png" alt="Logo" />
</a>
</div>
<!-- End Logo -->
</div>
</div>
</div>
<!-- End Header -->
<!-- Top Menu -->
<div id="hornav" class="bottom-border-shadow">
<div class="container no-padding border-bottom">
<div class="row">
<div class="col-md-8 no-padding">
<div class="visible-lg">
<ul id="hornavmenu" class="nav navbar-nav">
<li>
<a href="index.html" class="fa-home ">home</a>
</li>
<li>
<span class="fa-gears ">Malaria</span>
<ul>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/fivespecies">five Species</a>
</li>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/parasite">Parasite life cycle</a>
</li>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/definite">Definite and symptoms</a>
</li>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/currenttools">Current tools</a>
</li>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/malariatreatment">Malaria Treatment</a>
</li>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/history">History of antimalarials</a>
</li>
</ul>
</li>
<li>
<span class="fa-copy ">Access</span>
<ul>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/Areasofwork">Areas of work</a>
</li>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/mapofprojects">Map of Projects</a>
</li>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/toolkits">Tool kits</a>
</li>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/globalmalariamapper">Global malaria mapper</a>
</li>
<li>
<a href="<?php echo base_url() ?>index.php/Welcome/fivespecies">Access interviews</a>
</li>
</ul>
</li>
<li>
<span class="fa-th ">News room</span>
<ul>
<li>
<a href="portfolio-2-column.html">News</a>
</li>
<li>
<a href="portfolio-3-column.html">Press Releases</a>
</li>
<li>
<a href="portfolio-4-column.html">Publications</a>
</li>
<li>
<a href="portfolio-6-column.html">Events</a>
</li>
</ul>
</li>
<li>
<span class="fa-font ">Blog</span>
</li>
<li>
<a href="contact.html" class="fa-comment ">Drugs</a>
</li>
</ul>
</div>
</div>
<div class="col-md-4 no-padding">
<ul class="social-icons pull-right">
<li class="social-youtube">
<a href="https://www.youtube.com/user/MMVMeds4Malaria" target="_blank" title="Youtube"></a>
</li>
<li class="social-twitter">
<a href="https://twitter.com/MalariaNoMore?lang=en" target="_blank" title="Twitter"></a>
</li>
<li class="social-facebook">
<a href="https://www.facebook.com/pages/Antimalarial-medication/111604075529955" target="_blank" title="Facebook"></a>
</li>
<li class="social-googleplus">
<a href="https://plus.google.com/114702323662314783325" target="_blank" title="Google+"></a>
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- End Top Menu -->
<!-- === END HEADER === -->
&#13;
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
&#13;
答案 0 :(得分:1)
转到您的配置并将其更改为:
base_url http://localhost/
答案 1 :(得分:0)
在您的控制器构造函数中使用
加载URL帮助程序public function __construct() {
parent::__construct();
$this->load->helper('url');
}
在您的视图文件中....制作脚本和css路径如下(适用于所有)
示例:
替换
<link rel="stylesheet" href="assets/css/bootstrap.css" rel="stylesheet">
使用
<link rel="stylesheet" href="<?php echo base_url('assets/css/bootstrap.css');?>" rel="stylesheet">
确保您的资源文件夹必须位于根文件夹中。
答案 2 :(得分:0)
更改您的htaccess文件
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
也针对所有文件路径进行了更改。
<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/bootstrap.css" rel="stylesheet">
答案 3 :(得分:0)
向CSS中的所有链接添加资产/ 例 asset / css / nexus.css“ rel =” stylesheet“>