找不到对象!-Error 404-codeigniter-xampp server

时间:2016-09-29 08:38:34

标签: php codeigniter

控制器文件夹中的Pages.php



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

class Pages extends CI_Controller {

	public function index() {
        $this->load->view('header');
        $this->load->view('home');
        $this->load->view('footer');
	}
	public function fivespecies() {
        $this->load->view('header');
        $this->load->view('fivespecies');
        $this->load->view('footer');
	}
	
}
&#13;
&#13;
&#13;

配置文件夹中的autoload.php

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




$autoload['packages'] = array();


$autoload['libraries'] = array();


$autoload['drivers'] = array();


$autoload['helper'] = array('url');


$autoload['config'] = array();


$autoload['language'] = array();


$autoload['model'] = array();
&#13;
&#13;
&#13;

配置文件夹中的

config.php

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


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


$config['index_page'] = '';


$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;
&#13;
&#13;

配置文件夹中的

routes.php

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


$route['default_controller'] = 'pages';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['(:any)'] = 'pages/$1/$1';
&#13;
&#13;
&#13;

的header.php

&#13;
&#13;
<!-- === 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>&nbsp;9030051219
                        </div>
                        <div class="col-sm-6 text-right padding-vert-5">
                            <strong>Email:</strong>&nbsp;bioinformatics1416@gmail.com
                        </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="<?php echo base_url() ?>home">home</a>
                                    </li>
                                    <li>
                                        <span class="fa-gears ">Malaria</span>
                                        <ul>
                                            
                                            
                                    
                                            <li>
                                                <a href="<?php echo base_url() ?>fivespecies">fiveSpecies</a>
                                            </li>
                                            <li>
                                                <a href="features-accordions-tabs.html">Parasite life cycle</a>
                                            </li>
                                            <li>
                                                <a href="features-buttons.html">Definite and symptoms</a>
                                            </li>
                                            <li>
                                                <a href="features-carousels.html">Current tools</a>
                                            </li>
                                            <li>
                                                <a href="features-grid.html">Malaria Treatment</a>
                                            </li>
                                            <li>
                                                <a href="features-animate-on-scroll.html">History of antimalarials</a>
                                            </li>
                                        </ul>
                                    </li>
                                    <li>
                                        <span class="fa-copy ">Access</span>
                                        <ul>
                                            <li>
                                                <a href="pages-about-us.html">Areas of work</a>
                                            </li>
                                            <li>
                                                <a href="pages-services.html">Map of Projects</a>
                                            </li>
                                            <li>
                                                <a href="pages-faq.html">Products</a>
                                            </li>
                                            <li>
                                                <a href="pages-about-me.html">Tool kits</a>
                                            </li>
                                            <li>
                                                <a href="pages-full-width.html">Global malaria mapper</a>
                                            </li>
                                            <li>
                                                <a href="pages-left-sidebar.html">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>
                                        <ul>
                                            <li>
                                                <a href="blog-list.html">Blog</a>
                                            </li>
                                            <li>
                                                <a href="blog-single.html">Blog Single Item</a>
                                            </li>
                                        </ul>
                                    </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;
&#13;
&#13;

当我点击它显示的五种物种时(找不到物体错误) image

.htaccess文件

&#13;
&#13;
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

检查您是否在config.php中设置了基本网址

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/

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

尝试将此htaccess放在应用程序文件夹之外。我在windows上使用xampp,这个htaccess很好。

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]

如果您使用CI 3,则此处没有自动

$config['uri_protocol'] = 'AUTO';

更改为

$config['uri_protocol'] = 'REQUEST_URI';