Codeigniter showing 404 Page Not Found on Hostgator

痞子三分冷 提交于 2019-12-12 04:06:36

问题


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:


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



来源:https://stackoverflow.com/questions/29503934/codeigniter-showing-404-page-not-found-on-hostgator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!