在Web主机上传项目,找不到404页面

时间:2015-04-27 06:15:43

标签: codeigniter

我有codeigniter 3的问题,该项目在localhost中正常工作,但是当我在主机上传我的项目时,我看到了

  

未找到404页面

     

找不到您请求的页面。

我删除.httaccess文件,删除所有路由,但不工作。

我有两个控制器:

class test extends CI_Controller {}
class testen extends CI_Controller {}

我的htaccess文件:

<IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at
  #  http://www.example.com/mypage/test1
  # then use
  # RewriteBase /mypage/test1/
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* http://%1%{REQUEST_URI} [R=301,L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  # Submitted by: ElliotHaughin

  ErrorDocument 404 /index.php
</IfModule>

编辑: 我的路线:

$route['default_controller'] = 'isogamsharghedonya';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

$route["en"] = "isogamsharghedonyaen";
$route["fa"] = "isogamsharghedonya";

$route["en"] = "isogamsharghedonyaen/index";
$route["en/isogam-sharghe-donya-service"] = "isogamsharghedonyaen/service";
$route["en/isogam-sharghe-donya-news"] = "isogamsharghedonyaen/news";
$route["en/isogam-sharghe-donya-tvc"] = "isogamsharghedonyaen/video";
$route["en/isogam-sharghe-donya-certificate"] = "isogamsharghedonyaen/certificate";
$route["en/isogam-sharghe-donya-honor"] = "isogamsharghedonyaen/honor";
$route["en/isogam-sharghe-donya-ceo"] = "isogamsharghedonyaen/aboutCeo";
$route["en/isogam-sharghe-donya-about-company"] = "isogamsharghedonyaen/aboutCompany";
$route["en/isogam-sharghe-donya-team"] = "isogamsharghedonyaen/aboutTeam";
$route["en/isogam-sharghe-donya-contact"] = "isogamsharghedonyaen/contact";
$route["en/send-message"] = "isogamsharghedonyaen/sendMail";
$route["en/insulation-orders"] = "isogamsharghedonyaen/order";
$route["en/new-insulation-orders"] = "isogamsharghedonyaen/newOrder";


$route["fa"] = "isogamsharghedonya/index";
$route["fa/" . rawurlencode("خدمات-ایزوگام-شرق-دنیا")] = "isogamsharghedonya/service";
$route["fa/" . rawurlencode("اخبار-ایزوگام-شرق-دنیا")] = "isogamsharghedonya/news";
$route["fa/" . rawurlencode("تیزر-های-تبلیغاتی-ایزوگام-شرق-دنیا")] = "isogamsharghedonya/video";
$route["fa/" . rawurlencode("گواهینامه-ایزوگام-شرق-دنیا")] = "isogamsharghedonya/certificate";
$route["fa/" . rawurlencode("افتخارات-و-جوایز-ایزوگام-شرق-دنیا")] = "isogamsharghedonya/honor";
$route["fa/" . rawurlencode("مدیر-عامل-ایزوگام-شرق-دنیا")] = "isogamsharghedonya/aboutCeo";
$route["fa/" . rawurlencode("درباره-شرکت-ایزوگام-شرق-دنیا")] = "isogamsharghedonya/aboutCompany";
$route["fa/" . rawurlencode("تیم-ایزوگام-شرق-دنیا")] = "isogamsharghedonya/aboutTeam";
$route["fa/" . rawurlencode("تماس-با-ایزوگام-شرق-دنیا")] = "isogamsharghedonya/contact";
$route["fa/" . rawurlencode("ارسال-پیام")] = "isogamsharghedonya/sendMail";
$route["fa/" . rawurlencode("سفارش-ایزوگام")] = "isogamsharghedonya/order";
$route["fa/" . rawurlencode("سفارش-جدید-ایزوگام")] = "isogamsharghedonya/newOrder";

require_once (BASEPATH . 'database/DB' . EXT);
require_once (BASEPATH . 'helpers/url_helper' . EXT);
require_once (BASEPATH . 'helpers/text_helper' . EXT);
$db = &DB();

$query = $db -> get('news');
$result = $query -> result();
foreach ($result as $row) {
    $string = rawurlencode(str_replace(' ', '-', strtolower($row -> subjectFA)));
    $route["fa/news/" . $string] = "isogamsharghedonya/newsDetails/$row->id";
}

$query = $db -> get('news');
$result = $query -> result();
foreach ($result as $row) {
    $string = rawurlencode(str_replace(' ', '-', strtolower($row -> subjectEN)));
    $route["en/news/" . $string] = "isogamsharghedonyaen/newsDetails/$row->id";
}

$query = $db -> get('product');
$result = $query -> result();
foreach ($result as $row) {
    $string = rawurlencode(str_replace(' ', '-', strtolower($row -> nameFA)));
    $route["fa/product/" . $string] = "isogamsharghedonya/productDetails/$row->id";
}

$query = $db -> get('product');
$result = $query -> result();
foreach ($result as $row) {
    $string = rawurlencode(str_replace(' ', '-', strtolower($row -> nameEN)));
    $route["en/product/" . $string] = "isogamsharghedonyaen/productDetails/$row->id";
}

$query = $db -> get('trailer');
$result = $query -> result();
foreach ($result as $row) {
    $string = rawurlencode(str_replace(' ', '-', strtolower($row -> nameFA)));
    $route["fa/video/" . $string] = "isogamsharghedonya/videoDetails/$row->id";
}

$query = $db -> get('trailer');
$result = $query -> result();
foreach ($result as $row) {
    $string = rawurlencode(str_replace(' ', '-', strtolower($row -> nameEN)));
    $route["en/video/" . $string] = "isogamsharghedonyaen/videoDetails/$row->id";
}

2 个答案:

答案 0 :(得分:0)

您的控制器和型号文件必须以大写字母开头。 例如:controllers / Index.php,models / Index_model.php

用于控制器加载的CI 3核心中的

代码(/system/core/router.php):

protected function _set_default_controller()     {

    //... blah-blah-blah ...

    if ( ! file_exists(APPPATH.'controllers/'.$this->directory.ucfirst($class).'.php'))
    {
        // This will trigger 404 later
        return;
    }

    //...blah-blah-blah...

}

它在localhost中工作,因为您的系统是Windows。类Unix系统在处理文件时区分大小写。

答案 1 :(得分:-1)

在我审核您的代码时,您首先要纠正的是您声明控制器的方式,因为将控制器定义为class Test extends CI_Controller而不是class test extends CI_Controller是一种很好的做法声明某些时候可能会产生错误,第二件事是您必须检查您的.htaccess文件是否已上传到项目的根目录,以及您是否也检查了您的路径文件是否已编写相应的文件您声明的控制器的路由规则以及您的类中存在的方法,该方法在您的路由中定义