【问题标题】:404 Page Not Found The page you requested was not found.- CodeIgniter404 Page Not Found 找不到您请求的页面。- CodeIgniter
【发布时间】:2012-12-30 06:29:29
【问题描述】:

大家好,我尝试在 CodeIgniter 1.7.1 上工作,我已经完成了逐步安装 但它显示错误 404 页面未找到 未找到您请求的页面。

这是我使用的代码

控制器 home.php

class Home extends Controller {
       function __construct()
       {
        parent:: __construct();
        //$this->output->enable_profiler();
        $this->load->library('DX_Auth'); 

    } 

模型 homemodel.php

class HomeModel extends Model {


    function __construct()
    {
        // Call the Model constructor
        parent::Model();

    }

.htaccess

RewriteCond $1 !^(index\.php|assets|xcache|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 

我使用本地主机“XAMPP”

请帮帮我

和主index.php

<?php

    error_reporting(E_ALL);

    $system_folder = "system";


    $application_folder = "application";


if (strpos($system_folder, '/') === FALSE)
{
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    {
        $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
    }
}
else
{
    // Swap directory separators to Unix style for consistency
    $system_folder = str_replace("\\", "/", $system_folder); 
}


define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
define('FCPATH', __FILE__);
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');

if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}

/*
|---------------------------------------------------------------
| LOAD THE FRONT CONTROLLER
|---------------------------------------------------------------
|
| And away we go...
|
*/
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;

/* End of file index.php */
/* Location: ./index.php */

服务器错误致命错误:在第 21 行的 /hermes/bosoraweb075/b2180/ipg.djsaifnycom/paly/system/application/controllers/home.php 中找不到类“Memcache”

function index()
{
    $data['memcache'] = new Memcache;
    $data['memcache']->pconnect('localhost', 11211) or $memcache = false;
    //$this->output->cache(60);
    $this->load->model('dx_auth/UserModel', 'user');
    $this->load->model('homemodel');
    $data['title'] = "Home";

    if($this->dx_auth->is_logged_in())
    {
        $query = $this->user->get_user_by_id($this->session->userdata('DX_user_id'));
        //now we get personalized

        $row = $query->row();
        $data['feedFilter'] = $row->feed_filter;
        $data['feedView'] = $row->feed_view;
        if($data['feedFilter'] == 'tagged')
        {
            $data['feedList'] = null;
            $data['feedList'] = $data['memcache']->get('feed' . $data['feedFilter'] . $row->feed_view);
            if($data['feedList'] == null)
            {           
                $data['albums'] = $this->homemodel->getTagged();
            }
        } else {
            $data['feedList'] = null;
            $data['feedList'] = $data['memcache']->get('feed' . $data['feedFilter'] . $row->feed_view);
            if($data['feedList'] == null)
            {
                $data['albums'] = $this->homemodel->getFeedNoUser();
            }
        }
        //$this->output->enable_profiler();
        $this->template->write('title', 'Home');
        $this->template->write_view('content', 'home/index', $data, TRUE);
        $this->template->render();


    } else {
        $data['feedFilter'] = 'all';
        $this->load->helper('cookie');
        if(get_cookie('unravel_feedView'))
        {
            $data['feedView'] = 0;
        } else {
            $data['feedView'] = 1;
        }

        //this would be generic feed here
        $data['feedList'] = null;
        $data['feedList'] = $data['memcache']->get('feed' . $data['feedFilter'] . $data['feedView']);
        if($data['feedList'] == null)
        {
            $data['albums'] = $this->homemodel->getFeedNoUser();
        }
        $this->template->write('title', 'Home');
        $this->template->write_view('content', 'home/index', $data, TRUE);
        $this->template->render();
    }



    //$this->load->view('home/index', $data);
    //$this->output->enable_profiler(TRUE);
}

这条线是 $data['memcache'] = new Memcache;

【问题讨论】:

  • 您访问的是什么网址,您的 index.php 是否在网络根文件夹中?
  • 我使用 localhost/cashmusic
  • CI 2.1.3 发布October 8, 2012 可用时,您使用CI 1.7.1 发布February 10, 2009 是否有原因?如果你刚刚制作这个应用程序,你应该使用最新版本的 CI 来开发它。这么旧的版本很难提供支持。
  • 我使用它是因为这是一个由其他开发者开发的音乐应用程序,他们使用了它。我现在尝试使用它,如果你可以通过此链接查看完整源代码bitbucket.org/snaver/unravel-the-music/src/…请有任何解决方案来完美地使用它
  • 从上面的url看来,你的应用程序文件夹在你的系统文件夹中?如果是这种情况,您需要更新 index.php 以从正确的目录加载应用程序文件。 $application_folder = "system/application";

标签: php mysql codeigniter


【解决方案1】:

您可能还想检查您的httpd.conf 文件,看看是否允许 apache “尊重”您的 .htaccess 文件。搜索AllowOverride 命令并将其从AllowOverride None(默认)更改为AllowOverride All

另外:之后不要忘记重新启动 httpd 服务器。

【讨论】:

    【解决方案2】:

    也许 .htaccess 不在正确的目录中。你可能想检查它,应该在你的项目目录中。如果是的话,

    把它放在你的 .htaccess 文件中

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L]
    

    【讨论】:

    • 是的,它在正确的目录 localhost/cashmusic/.htaccess 没有老板仍然同样的错误
    • 好的老板,我安装在我的网络服务器上,但它给了我这个“致命错误:在 .../../.../paly/system/application/controllers 中找不到类 'Memcache' /home.php 在第 21 行,我将代码放在顶部
    • 也许您需要启用重写模块。a2enmod 重写然后重新启动您的 apache 服务器,您还需要安装 memcache。 sudo apt-get install php5-memcache
    猜你喜欢
    • 2018-04-18
    • 2016-01-12
    • 2013-07-06
    • 2018-04-18
    • 2014-02-16
    • 2017-10-13
    • 2017-06-19
    • 2013-01-13
    • 2020-12-05
    相关资源
    最近更新 更多