dongnanman9093 2015-04-08 00:41
浏览 45
已采纳

Codeigniter显示在Hostgator上找不到404页面

I'm currently testing my Codeigniter Project on my own Hostgator account. The project works well on my WAMP server but it shows a 404 Page Not Found error when online on Hostgator. I've tried playing around with the file permissions on FTP to playing around with the .htaccess file. The current site can be viewed here: www.test.jeffreyteruel.com.

Here's a look at my .htaccess file:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

My current file structure:

-application
-assets (css/js/img files) 
-cgi-bin(from the server) 
-system
-uploads
-.htaccess
-index.php

Here's my current config.php info:

$config['base_url'] = 'http://test.jeffreyteruel.com'; 
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

The default controller on the route.php file is: $route['default_controller'] = 'main';

Main Controller (main.php):

<?php defined('BASEPATH') OR exit('No direct script access allowed');
   class Main extends CI_Controller {
      public function __construct() 
      { 
         parent::__construct(); 
         //insert model here    
         $this->load->model('main_model'); 
         date_default_timezone_set('Asia/Manila');       
       } 
      public function index()
      { 
        $content['main_content'] = 'home/home'; 
        $this->load->view('main',$content);
      } 
  ...  
  ?> 

Any help to get the site showing properly would be appreciated.

  • 写回答

1条回答 默认 最新

  • dqthn68688 2015-04-08 01:14
    关注

    I have CI running on a subdomain on Hostgator and I recall a slight struggle getting it working but as I'm old I've got a memory like a.... Hmmm can't remember!

    My Simplified .htaccess is

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

    Addition:

    In your config.php

    $config['base_url'] = 'http://test.jeffreyteruel.com';      
    

    Add the trailing /

    $config['base_url'] = 'http://test.jeffreyteruel.com/';
    

    UPDATE:

    With Codeigniter 3 All Class names need to be Capitialized - First letter Uppercased ( ucfirst ). Refer to : codeigniter.com/userguide3/general/styleguide.html#file-naming

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?